diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebbaa260..d76a3e43 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,17 +1,19 @@ name: CI on: push: - branches: - - main - pull_request: - branches: - - main - - next + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: + timeout-minutes: 10 name: lint - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'stainless-sdks/orb-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + steps: - uses: actions/checkout@v4 @@ -21,7 +23,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle @@ -30,8 +32,9 @@ jobs: - name: Run lints run: ./scripts/lint test: + timeout-minutes: 10 name: test - runs-on: ubuntu-latest + runs-on: ${{ github.repository == 'stainless-sdks/orb-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 @@ -41,7 +44,7 @@ jobs: distribution: temurin java-version: | 8 - 17 + 21 cache: gradle - name: Set up Gradle diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index 66b43d31..96822978 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -33,7 +33,7 @@ jobs: export -- GPG_SIGNING_KEY_ID printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" - ./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" + ./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/.release-please-manifest.json b/.release-please-manifest.json index 87d3d84c..2afb750c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.56.0" + ".": "0.57.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 88277273..c71a786b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 106 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-e8dad7eee5621fe2ba948dfd00dabf170d9d92ce615a9f04b0f546f4d8bf39ba.yml openapi_spec_hash: 3f6a98e3a1b3a47acebd67a960090ebf -config_hash: 7e523cf79552b8936bd772f2e1025e5f +config_hash: f6da12790e8f46d93592def474d41c69 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d6c32c8..e90b3676 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,58 @@ # Changelog +## 0.57.0 (2025-05-22) + +Full Changelog: [v0.56.0...v0.57.0](https://github.com/orbcorp/orb-java/compare/v0.56.0...v0.57.0) + +### ⚠ BREAKING CHANGES + +* **client:** improve some class names +* **client:** extract auto pagination to shared classes +* **client:** **Migration:** - If you were referencing the `AutoPager` class on a specific `*Page` or `*PageAsync` type, then you should instead reference the shared `AutoPager` and `AutoPagerAsync` types, under the `core` package + - `AutoPagerAsync` now has different usage. You can call `.subscribe(...)` on the returned object instead to get called back each page item. You can also call `onCompleteFuture()` to get a future that completes when all items have been processed. Finally, you can call `.close()` on the returned object to stop auto-paginating early + - If you were referencing `getNextPage` or `getNextPageParams`: + - Swap to `nextPage()` and `nextPageParams()` + - Note that these both now return non-optional types (use `hasNextPage()` before calling these, since they will throw if it's impossible to get another page) + +### Features + +* **client:** allow providing some params positionally ([7ddd872](https://github.com/orbcorp/orb-java/commit/7ddd872ee4fb49e2e3f4b6d5938bc9a5ed0e2342)) +* **client:** extract auto pagination to shared classes ([9affbde](https://github.com/orbcorp/orb-java/commit/9affbdee875bdf75fa150d58ed8de23b9d51eaf2)) + + +### Bug Fixes + +* **internal:** fix name collision errors from Unit import ([1f7beef](https://github.com/orbcorp/orb-java/commit/1f7beefa05c6cb1356d1973bbcb0955f7eb65fbd)) + + +### Performance Improvements + +* **internal:** improve compilation+test speed ([f72c4ad](https://github.com/orbcorp/orb-java/commit/f72c4ad7c4604330f2ff972b517b2e3f03f5356f)) + + +### Chores + +* **ci:** only use depot for staging repos ([68dcdd8](https://github.com/orbcorp/orb-java/commit/68dcdd85f1eac797fae1136e383afae1ad5c0e28)) +* **ci:** run on more branches and use depot runners ([ddcc77e](https://github.com/orbcorp/orb-java/commit/ddcc77e1835fe8ec200fbfeb5d0427ef19fb6d25)) +* **docs:** grammar improvements ([7b5fb07](https://github.com/orbcorp/orb-java/commit/7b5fb07cdbe4b1ac8f41d95de243b913fce60a13)) +* **internal:** codegen related update ([9df208b](https://github.com/orbcorp/orb-java/commit/9df208bf6cf18c90cc09bf1f3eba9ba1e5b4c767)) +* **internal:** codegen related update ([7db8db6](https://github.com/orbcorp/orb-java/commit/7db8db63862be728dc201e36aa3ff164307c5e4e)) +* **internal:** java 17 -> 21 on ci ([7f2fb10](https://github.com/orbcorp/orb-java/commit/7f2fb1063cd794a4c46fb88203944d4262a0a1db)) +* **internal:** remove flaky `-Xbackend-threads=0` option ([b085373](https://github.com/orbcorp/orb-java/commit/b085373fc56676f510a0b0900e8cecd2af633313)) +* **internal:** update java toolchain ([2b4abdf](https://github.com/orbcorp/orb-java/commit/2b4abdff056e4bd158c6a2bc605c4ba09e4760d0)) + + +### Documentation + +* **client:** update jackson compat error message ([b3ceb27](https://github.com/orbcorp/orb-java/commit/b3ceb2741476209419bd210d7caebec7fbb5eaa7)) +* explain http client customization ([31827ac](https://github.com/orbcorp/orb-java/commit/31827acf060986c871832a7619f09dae7aab1640)) +* explain jackson compat in readme ([fb2505d](https://github.com/orbcorp/orb-java/commit/fb2505d8cdf9fb61589715396da17d424de5f7c0)) + + +### Refactors + +* **client:** improve some class names ([9460c52](https://github.com/orbcorp/orb-java/commit/9460c523ec5235f4b8b6335336be8e3b82b8527f)) + ## 0.56.0 (2025-04-09) Full Changelog: [v0.55.0...v0.56.0](https://github.com/orbcorp/orb-java/compare/v0.55.0...v0.56.0) diff --git a/README.md b/README.md index 6bb662be..fd591b88 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.56.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.57.0) @@ -19,7 +19,7 @@ The REST API documentation can be found on [docs.withorb.com](https://docs.witho ### Gradle ```kotlin -implementation("com.withorb.api:orb-java:0.56.0") +implementation("com.withorb.api:orb-java:0.57.0") ``` ### Maven @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:0.56.0") com.withorb.api orb-java - 0.56.0 + 0.57.0 ``` @@ -215,53 +215,101 @@ The SDK throws custom unchecked exception types: ## Pagination -For methods that return a paginated list of results, this library provides convenient ways access the results either one page at a time, or item-by-item across all pages. +The SDK defines methods that return a paginated lists of results. It provides convenient ways to access the results either one page at a time or item-by-item across all pages. ### Auto-pagination -To iterate through all results across all pages, you can use `autoPager`, which automatically handles fetching more pages for you: +To iterate through all results across all pages, use the `autoPager()` method, which automatically fetches more pages as needed. -### Synchronous +When using the synchronous client, the method returns an [`Iterable`](https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html) ```java import com.withorb.api.models.Coupon; import com.withorb.api.models.CouponListPage; -// As an Iterable: -CouponListPage page = client.coupons().list(params); +CouponListPage page = client.coupons().list(); + +// Process as an Iterable for (Coupon coupon : page.autoPager()) { System.out.println(coupon); -}; +} -// As a Stream: -client.coupons().list(params).autoPager().stream() +// Process as a Stream +page.autoPager() + .stream() .limit(50) .forEach(coupon -> System.out.println(coupon)); ``` -### Asynchronous +When using the asynchronous client, the method returns an [`AsyncStreamResponse`](orb-java-core/src/main/kotlin/com/withorb/api/core/http/AsyncStreamResponse.kt): ```java -// Using forEach, which returns CompletableFuture: -asyncClient.coupons().list(params).autoPager() - .forEach(coupon -> System.out.println(coupon), executor); +import com.withorb.api.core.http.AsyncStreamResponse; +import com.withorb.api.models.Coupon; +import com.withorb.api.models.CouponListPageAsync; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +CompletableFuture pageFuture = client.async().coupons().list(); + +pageFuture.thenRun(page -> page.autoPager().subscribe(coupon -> { + System.out.println(coupon); +})); + +// If you need to handle errors or completion of the stream +pageFuture.thenRun(page -> page.autoPager().subscribe(new AsyncStreamResponse.Handler<>() { + @Override + public void onNext(Coupon coupon) { + System.out.println(coupon); + } + + @Override + public void onComplete(Optional error) { + if (error.isPresent()) { + System.out.println("Something went wrong!"); + throw new RuntimeException(error.get()); + } else { + System.out.println("No more!"); + } + } +})); + +// Or use futures +pageFuture.thenRun(page -> page.autoPager() + .subscribe(coupon -> { + System.out.println(coupon); + }) + .onCompleteFuture() + .whenComplete((unused, error) -> { + if (error != null) { + System.out.println("Something went wrong!"); + throw new RuntimeException(error); + } else { + System.out.println("No more!"); + } + })); ``` ### Manual pagination -If none of the above helpers meet your needs, you can also manually request pages one-by-one. A page of results has a `data()` method to fetch the list of objects, as well as top-level `response` and other methods to fetch top-level data about the page. It also has methods `hasNextPage`, `getNextPage`, and `getNextPageParams` methods to help with pagination. +To access individual page items and manually request the next page, use the `items()`, +`hasNextPage()`, and `nextPage()` methods: ```java import com.withorb.api.models.Coupon; import com.withorb.api.models.CouponListPage; -CouponListPage page = client.coupons().list(params); -while (page != null) { - for (Coupon coupon : page.data()) { +CouponListPage page = client.coupons().list(); +while (true) { + for (Coupon coupon : page.items()) { System.out.println(coupon); } - page = page.getNextPage().orElse(null); + if (!page.hasNextPage()) { + break; + } + + page = page.nextPage(); } ``` @@ -291,6 +339,17 @@ 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. +## 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. + +The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config). + +If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`OrbOkHttpClient`](orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt) or [`OrbOkHttpClientAsync`](orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt). + +> [!CAUTION] +> We make no guarantee that the SDK works correctly when the Jackson version check is disabled. + ## Network options ### Retries @@ -327,7 +386,6 @@ To set a custom timeout, configure the method call using the `timeout` method: ```java import com.withorb.api.models.Customer; -import com.withorb.api.models.CustomerCreateParams; Customer customer = client.customers().create( params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() @@ -367,6 +425,42 @@ OrbClient client = OrbOkHttpClient.builder() .build(); ``` +### Custom HTTP client + +The SDK consists of three artifacts: + +- `orb-java-core` + - Contains core SDK logic + - Does not depend on [OkHttp](https://square.github.io/okhttp) + - Exposes [`OrbClient`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClient.kt), [`OrbClientAsync`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsync.kt), [`OrbClientImpl`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt), and [`OrbClientAsyncImpl`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt), all of which can work with any HTTP client +- `orb-java-client-okhttp` + - Depends on [OkHttp](https://square.github.io/okhttp) + - Exposes [`OrbOkHttpClient`](orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt) and [`OrbOkHttpClientAsync`](orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt), which provide a way to construct [`OrbClientImpl`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt) and [`OrbClientAsyncImpl`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt), respectively, using OkHttp +- `orb-java` + - Depends on and exposes the APIs of both `orb-java-core` and `orb-java-client-okhttp` + - Does not have its own logic + +This structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies. + +#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) + +> [!TIP] +> Try the available [network options](#network-options) before replacing the default client. + +To use a customized `OkHttpClient`: + +1. Replace your [`orb-java` dependency](#installation) with `orb-java-core` +2. Copy `orb-java-client-okhttp`'s [`OkHttpClient`](orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OkHttpClient.kt) class into your code and customize it +3. Construct [`OrbClientImpl`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt) or [`OrbClientAsyncImpl`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt), similarly to [`OrbOkHttpClient`](orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt) or [`OrbOkHttpClientAsync`](orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt), using your customized client + +### Completely custom HTTP client + +To use a completely custom HTTP client: + +1. Replace your [`orb-java` dependency](#installation) with `orb-java-core` +2. Write a class that implements the [`HttpClient`](orb-java-core/src/main/kotlin/com/withorb/api/core/http/HttpClient.kt) interface +3. Construct [`OrbClientImpl`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientImpl.kt) or [`OrbClientAsyncImpl`](orb-java-core/src/main/kotlin/com/withorb/api/client/OrbClientAsyncImpl.kt), similarly to [`OrbOkHttpClient`](orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClient.kt) or [`OrbOkHttpClientAsync`](orb-java-client-okhttp/src/main/kotlin/com/withorb/api/client/okhttp/OrbOkHttpClientAsync.kt), using your new client class + ## Undocumented API functionality The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. @@ -540,7 +634,6 @@ Or configure the method call to validate the response using the `responseValidat ```java import com.withorb.api.models.Customer; -import com.withorb.api.models.CustomerCreateParams; Customer customer = client.customers().create( params, RequestOptions.builder().responseValidation(true).build() diff --git a/SECURITY.md b/SECURITY.md index 6f64d22c..3011c342 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -16,11 +16,11 @@ before making any information public. ## Reporting Non-SDK Related Security Issues If you encounter security issues that are not directly related to SDKs but pertain to the services -or products provided by Orb please follow the respective company's security reporting guidelines. +or products provided by Orb, please follow the respective company's security reporting guidelines. ### Orb Terms and Policies -Please contact team@withorb.com for any questions or concerns regarding security of our services. +Please contact team@withorb.com for any questions or concerns regarding the security of our services. --- diff --git a/build.gradle.kts b/build.gradle.kts index 3973ccca..5f840836 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ allprojects { group = "com.withorb.api" - version = "0.56.0" // x-release-please-version + version = "0.57.0" // x-release-please-version } diff --git a/buildSrc/src/main/kotlin/orb.java.gradle.kts b/buildSrc/src/main/kotlin/orb.java.gradle.kts index e39d9ac6..dfbacb86 100644 --- a/buildSrc/src/main/kotlin/orb.java.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.java.gradle.kts @@ -21,7 +21,7 @@ configure { java { toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } sourceCompatibility = JavaVersion.VERSION_1_8 diff --git a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts index 55b2fc55..2d4a5c55 100644 --- a/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/orb.kotlin.gradle.kts @@ -9,7 +9,7 @@ plugins { kotlin { jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(17)) + languageVersion.set(JavaLanguageVersion.of(21)) } compilerOptions { @@ -34,8 +34,7 @@ configure { } } -// Run tests in parallel to some degree. tasks.withType().configureEach { - maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) - forkEvery = 100 + systemProperty("junit.jupiter.execution.parallel.enabled", true) + systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") } diff --git a/gradle.properties b/gradle.properties index 0c8d4ded..ff76593f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,17 @@ org.gradle.caching=true +org.gradle.configuration-cache=true org.gradle.parallel=true org.gradle.daemon=false -org.gradle.jvmargs=-Xmx4g -kotlin.daemon.jvmargs=-Xmx4g +# These options improve our compilation and test performance. They are inherited by the Kotlin daemon. +org.gradle.jvmargs=\ + -Xms1g \ + -Xmx4g \ + -XX:+UseParallelGC \ + -XX:InitialCodeCacheSize=256m \ + -XX:ReservedCodeCacheSize=1G \ + -XX:MetaspaceSize=256m \ + -XX:TieredStopAtLevel=1 \ + -XX:GCTimeRatio=4 \ + -XX:CICompilerCount=4 \ + -XX:+OptimizeStringConcat \ + -XX:+UseStringDeduplication 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 458d3da8..df13e8b1 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 @@ -13,6 +13,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.Executor import kotlin.jvm.optionals.getOrNull class OrbOkHttpClient private constructor() { @@ -47,6 +48,10 @@ class OrbOkHttpClient private constructor() { fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + clientOptions.streamHandlerExecutor(streamHandlerExecutor) + } + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } fun headers(headers: Headers) = apply { clientOptions.headers(headers) } 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 f8d51c09..b0396fb6 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 @@ -13,6 +13,7 @@ import java.net.Proxy import java.time.Clock import java.time.Duration import java.util.Optional +import java.util.concurrent.Executor import kotlin.jvm.optionals.getOrNull class OrbOkHttpClientAsync private constructor() { @@ -47,6 +48,10 @@ class OrbOkHttpClientAsync private constructor() { fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + clientOptions.streamHandlerExecutor(streamHandlerExecutor) + } + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } fun headers(headers: Headers) = apply { clientOptions.headers(headers) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/AutoPager.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/AutoPager.kt new file mode 100644 index 00000000..87762a7c --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/AutoPager.kt @@ -0,0 +1,21 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core + +import java.util.stream.Stream +import java.util.stream.StreamSupport + +class AutoPager private constructor(private val firstPage: Page) : Iterable { + + companion object { + + fun from(firstPage: Page): AutoPager = AutoPager(firstPage) + } + + override fun iterator(): Iterator = + generateSequence(firstPage) { if (it.hasNextPage()) it.nextPage() else null } + .flatMap { it.items() } + .iterator() + + fun stream(): Stream = StreamSupport.stream(spliterator(), false) +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/AutoPagerAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/AutoPagerAsync.kt new file mode 100644 index 00000000..beeade0a --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/AutoPagerAsync.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core + +import com.withorb.api.core.http.AsyncStreamResponse +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.CompletionException +import java.util.concurrent.Executor +import java.util.concurrent.atomic.AtomicReference + +class AutoPagerAsync +private constructor(private val firstPage: PageAsync, private val defaultExecutor: Executor) : + AsyncStreamResponse { + + companion object { + + fun from(firstPage: PageAsync, defaultExecutor: Executor): AutoPagerAsync = + AutoPagerAsync(firstPage, defaultExecutor) + } + + private val onCompleteFuture = CompletableFuture() + private val state = AtomicReference(State.NEW) + + override fun subscribe(handler: AsyncStreamResponse.Handler): AsyncStreamResponse = + subscribe(handler, defaultExecutor) + + override fun subscribe( + handler: AsyncStreamResponse.Handler, + executor: Executor, + ): AsyncStreamResponse = apply { + // TODO(JDK): Use `compareAndExchange` once targeting JDK 9. + check(state.compareAndSet(State.NEW, State.SUBSCRIBED)) { + if (state.get() == State.SUBSCRIBED) "Cannot subscribe more than once" + else "Cannot subscribe after the response is closed" + } + + fun PageAsync.handle(): CompletableFuture { + if (state.get() == State.CLOSED) { + return CompletableFuture.completedFuture(null) + } + + items().forEach { handler.onNext(it) } + return if (hasNextPage()) nextPage().thenCompose { it.handle() } + else CompletableFuture.completedFuture(null) + } + + executor.execute { + firstPage.handle().whenComplete { _, error -> + val actualError = + if (error is CompletionException && error.cause != null) error.cause else error + try { + handler.onComplete(Optional.ofNullable(actualError)) + } finally { + try { + if (actualError == null) { + onCompleteFuture.complete(null) + } else { + onCompleteFuture.completeExceptionally(actualError) + } + } finally { + close() + } + } + } + } + } + + override fun onCompleteFuture(): CompletableFuture = onCompleteFuture + + override fun close() { + val previousState = state.getAndSet(State.CLOSED) + if (previousState == State.CLOSED) { + return + } + + // When the stream is closed, we should always consider it closed. If it closed due + // to an error, then we will have already completed the future earlier, and this + // will be a no-op. + onCompleteFuture.complete(null) + } +} + +private enum class State { + NEW, + SUBSCRIBED, + CLOSED, +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt index df5773f1..a88b2cbb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Check.kt @@ -5,6 +5,9 @@ package com.withorb.api.core import com.fasterxml.jackson.core.Version import com.fasterxml.jackson.core.util.VersionUtil +fun checkRequired(name: String, condition: Boolean) = + check(condition) { "`$name` is required, but was not set" } + fun checkRequired(name: String, value: T?): T = checkNotNull(value) { "`$name` is required, but was not set" } @@ -62,7 +65,7 @@ internal fun checkJacksonVersionCompatibility() { } check(incompatibleJacksonVersions.isEmpty()) { """ -This SDK depends on Jackson version $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: +This SDK requires a minimum Jackson version of $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: ${incompatibleJacksonVersions.asSequence().map { (version, incompatibilityReason) -> "- `${version.toFullString().replace("/", ":")}` ($incompatibilityReason)" @@ -73,6 +76,8 @@ This can happen if you are either: 2. Depending on some library that depends on different Jackson versions, potentially transitively Double-check that you are depending on compatible Jackson versions. + +See https://www.github.com/orbcorp/orb-java#jackson for more information. """ .trimIndent() } 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 33a56193..f1898f51 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 @@ -10,6 +10,10 @@ import com.withorb.api.core.http.QueryParams import com.withorb.api.core.http.RetryingHttpClient import java.time.Clock import java.util.Optional +import java.util.concurrent.Executor +import java.util.concurrent.Executors +import java.util.concurrent.ThreadFactory +import java.util.concurrent.atomic.AtomicLong import kotlin.jvm.optionals.getOrNull class ClientOptions @@ -18,6 +22,7 @@ private constructor( @get:JvmName("httpClient") val httpClient: HttpClient, @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + @get:JvmName("streamHandlerExecutor") val streamHandlerExecutor: Executor, @get:JvmName("clock") val clock: Clock, @get:JvmName("baseUrl") val baseUrl: String, @get:JvmName("headers") val headers: Headers, @@ -63,6 +68,7 @@ private constructor( private var httpClient: HttpClient? = null private var checkJacksonVersionCompatibility: Boolean = true private var jsonMapper: JsonMapper = jsonMapper() + private var streamHandlerExecutor: Executor? = null private var clock: Clock = Clock.systemUTC() private var baseUrl: String = PRODUCTION_URL private var headers: Headers.Builder = Headers.builder() @@ -78,6 +84,7 @@ private constructor( httpClient = clientOptions.originalHttpClient checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility jsonMapper = clientOptions.jsonMapper + streamHandlerExecutor = clientOptions.streamHandlerExecutor clock = clientOptions.clock baseUrl = clientOptions.baseUrl headers = clientOptions.headers.toBuilder() @@ -97,6 +104,10 @@ private constructor( fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + fun clock(clock: Clock) = apply { this.clock = clock } fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } @@ -251,6 +262,20 @@ private constructor( ), 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()}" + } + } + ), clock, baseUrl, headers.build(), diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/Page.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/Page.kt new file mode 100644 index 00000000..ff2e880d --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/Page.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core + +/** + * An interface representing a single page, with items of type [T], from a paginated endpoint + * response. + * + * Implementations of this interface are expected to request additional pages synchronously. For + * asynchronous pagination, see the [PageAsync] interface. + */ +interface Page { + + /** + * Returns whether there's another page after this one. + * + * The method generally doesn't make requests so the result depends entirely on the data in this + * page. If a significant amount of time has passed between requesting this page and calling + * this method, then the result could be stale. + */ + fun hasNextPage(): Boolean + + /** + * Returns the page after this one by making another request. + * + * @throws IllegalStateException if it's impossible to get the next page. This exception is + * avoidable by calling [hasNextPage] first. + */ + fun nextPage(): Page + + /** Returns the items in this page. */ + fun items(): List +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/PageAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/PageAsync.kt new file mode 100644 index 00000000..d97ddae0 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/PageAsync.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core + +import java.util.concurrent.CompletableFuture + +/** + * An interface representing a single page, with items of type [T], from a paginated endpoint + * response. + * + * Implementations of this interface are expected to request additional pages asynchronously. For + * synchronous pagination, see the [Page] interface. + */ +interface PageAsync { + + /** + * Returns whether there's another page after this one. + * + * The method generally doesn't make requests so the result depends entirely on the data in this + * page. If a significant amount of time has passed between requesting this page and calling + * this method, then the result could be stale. + */ + fun hasNextPage(): Boolean + + /** + * Returns the page after this one by making another request. + * + * @throws IllegalStateException if it's impossible to get the next page. This exception is + * avoidable by calling [hasNextPage] first. + */ + fun nextPage(): CompletableFuture> + + /** Returns the items in this page. */ + fun items(): List +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/AsyncStreamResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/AsyncStreamResponse.kt new file mode 100644 index 00000000..8b58fd92 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/AsyncStreamResponse.kt @@ -0,0 +1,157 @@ +package com.withorb.api.core.http + +import com.withorb.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.concurrent.atomic.AtomicReference + +/** + * A class providing access to an API response as an asynchronous stream of chunks of type [T], + * where each chunk can be individually processed as soon as it arrives instead of waiting on the + * full response. + */ +interface AsyncStreamResponse { + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the client's configured or default thread pool. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler): AsyncStreamResponse + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the given [executor]. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse + + /** + * Returns a future that completes when a stream is fully consumed, errors, or gets closed + * early. + */ + fun onCompleteFuture(): CompletableFuture + + /** + * Closes this resource, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because this response should not be + * synchronously closed via try-with-resources. + */ + fun close() + + /** A class for handling streaming events. */ + fun interface Handler { + + /** Called whenever a chunk is received. */ + fun onNext(value: T) + + /** + * Called when a stream is fully consumed, errors, or gets closed early. + * + * [onNext] will not be called once this method is called. + * + * @param error Non-empty if the stream completed due to an error. + */ + fun onComplete(error: Optional) {} + } +} + +@JvmSynthetic +internal fun CompletableFuture>.toAsync(streamHandlerExecutor: Executor) = + PhantomReachableClosingAsyncStreamResponse( + object : AsyncStreamResponse { + + private val onCompleteFuture = CompletableFuture() + private val state = AtomicReference(State.NEW) + + init { + this@toAsync.whenComplete { _, error -> + // If an error occurs from the original future, then we should resolve the + // `onCompleteFuture` even if `subscribe` has not been called. + error?.let(onCompleteFuture::completeExceptionally) + } + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = + subscribe(handler, streamHandlerExecutor) + + override fun subscribe( + handler: Handler, + executor: Executor, + ): AsyncStreamResponse = apply { + // TODO(JDK): Use `compareAndExchange` once targeting JDK 9. + check(state.compareAndSet(State.NEW, State.SUBSCRIBED)) { + if (state.get() == State.SUBSCRIBED) "Cannot subscribe more than once" + else "Cannot subscribe after the response is closed" + } + + this@toAsync.whenCompleteAsync( + { streamResponse, futureError -> + if (state.get() == State.CLOSED) { + // Avoid doing any work if `close` was called before the future + // completed. + return@whenCompleteAsync + } + + if (futureError != null) { + // An error occurred before we started passing chunks to the handler. + handler.onComplete(Optional.of(futureError)) + return@whenCompleteAsync + } + + var streamError: Throwable? = null + try { + streamResponse.stream().forEach(handler::onNext) + } catch (e: Throwable) { + streamError = e + } + + try { + handler.onComplete(Optional.ofNullable(streamError)) + } finally { + try { + // Notify completion via the `onCompleteFuture` as well. This is in + // a separate `try-finally` block so that we still complete the + // future if `handler.onComplete` throws. + if (streamError == null) { + onCompleteFuture.complete(null) + } else { + onCompleteFuture.completeExceptionally(streamError) + } + } finally { + close() + } + } + }, + executor, + ) + } + + override fun onCompleteFuture(): CompletableFuture = onCompleteFuture + + override fun close() { + val previousState = state.getAndSet(State.CLOSED) + if (previousState == State.CLOSED) { + return + } + + this@toAsync.whenComplete { streamResponse, error -> streamResponse?.close() } + // When the stream is closed, we should always consider it closed. If it closed due + // to an error, then we will have already completed the future earlier, and this + // will be a no-op. + onCompleteFuture.complete(null) + } + } + ) + +private enum class State { + NEW, + SUBSCRIBED, + CLOSED, +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt new file mode 100644 index 00000000..53a660b4 --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt @@ -0,0 +1,56 @@ +package com.withorb.api.core.http + +import com.withorb.api.core.closeWhenPhantomReachable +import com.withorb.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor + +/** + * A delegating wrapper around an `AsyncStreamResponse` that closes it once it's only phantom + * reachable. + * + * This class ensures the `AsyncStreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingAsyncStreamResponse( + private val asyncStreamResponse: AsyncStreamResponse +) : AsyncStreamResponse { + + /** + * An object used for keeping `asyncStreamResponse` open while the object is still reachable. + */ + private val reachabilityTracker = Object() + + init { + closeWhenPhantomReachable(reachabilityTracker, asyncStreamResponse::close) + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker)) + } + + override fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse = + apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker), executor) + } + + override fun onCompleteFuture(): CompletableFuture = + asyncStreamResponse.onCompleteFuture() + + override fun close() = asyncStreamResponse.close() +} + +/** + * A wrapper around a `Handler` that also references a `reachabilityTracker` object. + * + * Referencing the `reachabilityTracker` object prevents it from getting reclaimed while the handler + * is still reachable. + */ +private class TrackedHandler( + private val handler: Handler, + private val reachabilityTracker: Any, +) : Handler { + override fun onNext(value: T) = handler.onNext(value) + + override fun onComplete(error: Optional) = handler.onComplete(error) +} diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingStreamResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingStreamResponse.kt new file mode 100644 index 00000000..161638de --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/PhantomReachableClosingStreamResponse.kt @@ -0,0 +1,21 @@ +package com.withorb.api.core.http + +import com.withorb.api.core.closeWhenPhantomReachable +import java.util.stream.Stream + +/** + * A delegating wrapper around a `StreamResponse` that closes it once it's only phantom reachable. + * + * This class ensures the `StreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingStreamResponse( + private val streamResponse: StreamResponse +) : StreamResponse { + init { + closeWhenPhantomReachable(this, streamResponse) + } + + override fun stream(): Stream = streamResponse.stream() + + override fun close() = streamResponse.close() +} 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 93413092..cba6f15b 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 @@ -23,6 +23,7 @@ import kotlin.math.pow class RetryingHttpClient private constructor( private val httpClient: HttpClient, + private val sleeper: Sleeper, private val clock: Clock, private val maxRetries: Int, private val idempotencyHeader: String?, @@ -62,10 +63,10 @@ private constructor( null } - val backoffMillis = getRetryBackoffMillis(retries, response) + val backoffDuration = getRetryBackoffDuration(retries, response) // All responses must be closed, so close the failed one before retrying. response?.close() - Thread.sleep(backoffMillis.toMillis()) + sleeper.sleep(backoffDuration) } } @@ -111,10 +112,10 @@ private constructor( } } - val backoffMillis = getRetryBackoffMillis(retries, response) + val backoffDuration = getRetryBackoffDuration(retries, response) // All responses must be closed, so close the failed one before retrying. response?.close() - return sleepAsync(backoffMillis.toMillis()).thenCompose { + return sleeper.sleepAsync(backoffDuration).thenCompose { executeWithRetries(requestWithRetryCount, requestOptions) } } @@ -179,7 +180,7 @@ private constructor( // retried. throwable is IOException || throwable is OrbIoException - private fun getRetryBackoffMillis(retries: Int, response: HttpResponse?): Duration { + private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { // About the Retry-After header: // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After response @@ -226,33 +227,40 @@ private constructor( companion object { - private val TIMER = Timer("RetryingHttpClient", true) - - private fun sleepAsync(millis: Long): CompletableFuture { - val future = CompletableFuture() - TIMER.schedule( - object : TimerTask() { - override fun run() { - future.complete(null) - } - }, - millis, - ) - return future - } - @JvmStatic fun builder() = Builder() } 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 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 clock(clock: Clock) = apply { this.clock = clock } fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } @@ -262,9 +270,17 @@ private constructor( fun build(): HttpClient = RetryingHttpClient( checkRequired("httpClient", httpClient), + sleeper, 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/core/http/StreamResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/StreamResponse.kt new file mode 100644 index 00000000..9c6597ff --- /dev/null +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/http/StreamResponse.kt @@ -0,0 +1,19 @@ +package com.withorb.api.core.http + +import java.util.stream.Stream + +interface StreamResponse : AutoCloseable { + + fun stream(): Stream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} + +@JvmSynthetic +internal fun StreamResponse.map(transform: (T) -> R): StreamResponse = + object : StreamResponse { + override fun stream(): Stream = this@map.stream().map(transform) + + override fun close() = this@map.close() + } 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 c05cc280..7e5df171 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 @@ -33,13 +33,13 @@ import kotlin.jvm.optionals.getOrNull */ class AlertCreateForCustomerParams private constructor( - private val customerId: String, + private val customerId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) /** * The case sensitive currency or custom pricing unit to use for this alert. @@ -101,7 +101,6 @@ private constructor( * * The following fields are required: * ```java - * .customerId() * .currency() * .type() * ``` @@ -125,7 +124,10 @@ private constructor( additionalQueryParams = alertCreateForCustomerParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) /** * Sets the entire request body. @@ -308,7 +310,6 @@ private constructor( * * The following fields are required: * ```java - * .customerId() * .currency() * .type() * ``` @@ -317,7 +318,7 @@ private constructor( */ fun build(): AlertCreateForCustomerParams = AlertCreateForCustomerParams( - checkRequired("customerId", customerId), + customerId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -328,7 +329,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 73df3de4..d1787b4e 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 @@ -33,13 +33,13 @@ import kotlin.jvm.optionals.getOrNull */ class AlertCreateForExternalCustomerParams private constructor( - private val externalCustomerId: String, + private val externalCustomerId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun externalCustomerId(): String = externalCustomerId + fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) /** * The case sensitive currency or custom pricing unit to use for this alert. @@ -102,7 +102,6 @@ private constructor( * * The following fields are required: * ```java - * .externalCustomerId() * .currency() * .type() * ``` @@ -129,10 +128,16 @@ private constructor( alertCreateForExternalCustomerParams.additionalQueryParams.toBuilder() } - fun externalCustomerId(externalCustomerId: String) = apply { + fun externalCustomerId(externalCustomerId: String?) = apply { this.externalCustomerId = externalCustomerId } + /** + * Alias for calling [Builder.externalCustomerId] with `externalCustomerId.orElse(null)`. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.getOrNull()) + /** * Sets the entire request body. * @@ -314,7 +319,6 @@ private constructor( * * The following fields are required: * ```java - * .externalCustomerId() * .currency() * .type() * ``` @@ -323,7 +327,7 @@ private constructor( */ fun build(): AlertCreateForExternalCustomerParams = AlertCreateForExternalCustomerParams( - checkRequired("externalCustomerId", externalCustomerId), + externalCustomerId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -334,7 +338,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalCustomerId + 0 -> externalCustomerId ?: "" else -> "" } 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 00d15efb..6cc5c393 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 @@ -37,13 +37,13 @@ import kotlin.jvm.optionals.getOrNull */ class AlertCreateForSubscriptionParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * The thresholds that define the values at which the alert will be triggered. @@ -106,7 +106,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .thresholds() * .type() * ``` @@ -132,7 +131,11 @@ private constructor( alertCreateForSubscriptionParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Sets the entire request body. @@ -315,7 +318,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .thresholds() * .type() * ``` @@ -324,7 +326,7 @@ private constructor( */ fun build(): AlertCreateForSubscriptionParams = AlertCreateForSubscriptionParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -335,7 +337,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } 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 f0fb5a14..0e1f15a1 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 @@ -4,7 +4,6 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -19,14 +18,14 @@ import kotlin.jvm.optionals.getOrNull */ class AlertDisableParams private constructor( - private val alertConfigurationId: String, + private val alertConfigurationId: String?, private val subscriptionId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun alertConfigurationId(): String = alertConfigurationId + fun alertConfigurationId(): Optional = Optional.ofNullable(alertConfigurationId) /** Used to update the status of a plan alert scoped to this subscription_id */ fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) @@ -41,14 +40,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AlertDisableParams]. - * - * The following fields are required: - * ```java - * .alertConfigurationId() - * ``` - */ + @JvmStatic fun none(): AlertDisableParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AlertDisableParams]. */ @JvmStatic fun builder() = Builder() } @@ -70,10 +64,17 @@ private constructor( additionalBodyProperties = alertDisableParams.additionalBodyProperties.toMutableMap() } - fun alertConfigurationId(alertConfigurationId: String) = apply { + fun alertConfigurationId(alertConfigurationId: String?) = apply { this.alertConfigurationId = alertConfigurationId } + /** + * Alias for calling [Builder.alertConfigurationId] with + * `alertConfigurationId.orElse(null)`. + */ + fun alertConfigurationId(alertConfigurationId: Optional) = + alertConfigurationId(alertConfigurationId.getOrNull()) + /** Used to update the status of a plan alert scoped to this subscription_id */ fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } @@ -205,17 +206,10 @@ private constructor( * Returns an immutable instance of [AlertDisableParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .alertConfigurationId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AlertDisableParams = AlertDisableParams( - checkRequired("alertConfigurationId", alertConfigurationId), + alertConfigurationId, subscriptionId, additionalHeaders.build(), additionalQueryParams.build(), @@ -228,7 +222,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> alertConfigurationId + 0 -> alertConfigurationId ?: "" else -> "" } 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 beb1c38c..726e00d0 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 @@ -4,7 +4,6 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -19,14 +18,14 @@ import kotlin.jvm.optionals.getOrNull */ class AlertEnableParams private constructor( - private val alertConfigurationId: String, + private val alertConfigurationId: String?, private val subscriptionId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun alertConfigurationId(): String = alertConfigurationId + fun alertConfigurationId(): Optional = Optional.ofNullable(alertConfigurationId) /** Used to update the status of a plan alert scoped to this subscription_id */ fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) @@ -41,14 +40,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AlertEnableParams]. - * - * The following fields are required: - * ```java - * .alertConfigurationId() - * ``` - */ + @JvmStatic fun none(): AlertEnableParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AlertEnableParams]. */ @JvmStatic fun builder() = Builder() } @@ -70,10 +64,17 @@ private constructor( additionalBodyProperties = alertEnableParams.additionalBodyProperties.toMutableMap() } - fun alertConfigurationId(alertConfigurationId: String) = apply { + fun alertConfigurationId(alertConfigurationId: String?) = apply { this.alertConfigurationId = alertConfigurationId } + /** + * Alias for calling [Builder.alertConfigurationId] with + * `alertConfigurationId.orElse(null)`. + */ + fun alertConfigurationId(alertConfigurationId: Optional) = + alertConfigurationId(alertConfigurationId.getOrNull()) + /** Used to update the status of a plan alert scoped to this subscription_id */ fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } @@ -205,17 +206,10 @@ private constructor( * Returns an immutable instance of [AlertEnableParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .alertConfigurationId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AlertEnableParams = AlertEnableParams( - checkRequired("alertConfigurationId", alertConfigurationId), + alertConfigurationId, subscriptionId, additionalHeaders.build(), additionalQueryParams.build(), @@ -228,7 +222,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> alertConfigurationId + 0 -> alertConfigurationId ?: "" else -> "" } 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 e34c1eaf..626b3e7e 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.AlertService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [AlertService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: AlertService, private val params: AlertListParams, private val response: AlertListPageResponse, -) { +) : Page { /** * Delegates to [AlertListPageResponse], but gracefully handles missing data. @@ -33,30 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): AlertListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): AlertListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): AlertListParams = params @@ -125,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: AlertListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 8a37ce8d..ff9b1277 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.AlertServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [AlertServiceAsync.list] */ class AlertListPageAsync private constructor( private val service: AlertServiceAsync, + private val streamHandlerExecutor: Executor, private val params: AlertListParams, private val response: AlertListPageResponse, -) { +) : PageAsync { /** * Delegates to [AlertListPageResponse], but gracefully handles missing data. @@ -34,33 +36,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): AlertListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): AlertListParams = params @@ -78,6 +69,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -89,18 +81,24 @@ private constructor( class Builder internal constructor() { private var service: AlertServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: AlertListParams? = null private var response: AlertListPageResponse? = null @JvmSynthetic internal fun from(alertListPageAsync: AlertListPageAsync) = apply { service = alertListPageAsync.service + streamHandlerExecutor = alertListPageAsync.streamHandlerExecutor params = alertListPageAsync.params response = alertListPageAsync.response } fun service(service: AlertServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: AlertListParams) = apply { this.params = params } @@ -115,6 +113,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -124,47 +123,22 @@ private constructor( fun build(): AlertListPageAsync = AlertListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: AlertListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Alert) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AlertListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is AlertListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "AlertListPageAsync{service=$service, params=$params, response=$response}" + "AlertListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 0f01a409..1f780152 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 @@ -3,20 +3,21 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** This endpoint retrieves an alert by its ID. */ class AlertRetrieveParams private constructor( - private val alertId: String, + private val alertId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun alertId(): String = alertId + fun alertId(): Optional = Optional.ofNullable(alertId) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [AlertRetrieveParams]. - * - * The following fields are required: - * ```java - * .alertId() - * ``` - */ + @JvmStatic fun none(): AlertRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AlertRetrieveParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = alertRetrieveParams.additionalQueryParams.toBuilder() } - fun alertId(alertId: String) = apply { this.alertId = alertId } + fun alertId(alertId: String?) = apply { this.alertId = alertId } + + /** Alias for calling [Builder.alertId] with `alertId.orElse(null)`. */ + fun alertId(alertId: Optional) = alertId(alertId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,25 +154,14 @@ private constructor( * Returns an immutable instance of [AlertRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .alertId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): AlertRetrieveParams = - AlertRetrieveParams( - checkRequired("alertId", alertId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + AlertRetrieveParams(alertId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> alertId + 0 -> alertId ?: "" else -> "" } 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 f61a35f6..6dda2bc8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt @@ -19,18 +19,19 @@ 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 /** This endpoint updates the thresholds of an alert. */ class AlertUpdateParams private constructor( - private val alertConfigurationId: String, + private val alertConfigurationId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun alertConfigurationId(): String = alertConfigurationId + fun alertConfigurationId(): Optional = Optional.ofNullable(alertConfigurationId) /** * The thresholds that define the values at which the alert will be triggered. @@ -62,7 +63,6 @@ private constructor( * * The following fields are required: * ```java - * .alertConfigurationId() * .thresholds() * ``` */ @@ -85,10 +85,17 @@ private constructor( additionalQueryParams = alertUpdateParams.additionalQueryParams.toBuilder() } - fun alertConfigurationId(alertConfigurationId: String) = apply { + fun alertConfigurationId(alertConfigurationId: String?) = apply { this.alertConfigurationId = alertConfigurationId } + /** + * Alias for calling [Builder.alertConfigurationId] with + * `alertConfigurationId.orElse(null)`. + */ + fun alertConfigurationId(alertConfigurationId: Optional) = + alertConfigurationId(alertConfigurationId.getOrNull()) + /** * Sets the entire request body. * @@ -243,7 +250,6 @@ private constructor( * * The following fields are required: * ```java - * .alertConfigurationId() * .thresholds() * ``` * @@ -251,7 +257,7 @@ private constructor( */ fun build(): AlertUpdateParams = AlertUpdateParams( - checkRequired("alertConfigurationId", alertConfigurationId), + alertConfigurationId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -262,7 +268,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> alertConfigurationId + 0 -> alertConfigurationId ?: "" else -> "" } 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 c1dfe5f3..f8cff3dc 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint allows a coupon to be archived. Archived coupons can no longer be redeemed, and @@ -18,13 +18,13 @@ import java.util.Optional */ class CouponArchiveParams private constructor( - private val couponId: String, + private val couponId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun couponId(): String = couponId + fun couponId(): Optional = Optional.ofNullable(couponId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CouponArchiveParams]. - * - * The following fields are required: - * ```java - * .couponId() - * ``` - */ + @JvmStatic fun none(): CouponArchiveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CouponArchiveParams]. */ @JvmStatic fun builder() = Builder() } @@ -63,7 +58,10 @@ private constructor( additionalBodyProperties = couponArchiveParams.additionalBodyProperties.toMutableMap() } - fun couponId(couponId: String) = apply { this.couponId = couponId } + fun couponId(couponId: String?) = apply { this.couponId = couponId } + + /** Alias for calling [Builder.couponId] with `couponId.orElse(null)`. */ + fun couponId(couponId: Optional) = couponId(couponId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -189,17 +187,10 @@ private constructor( * Returns an immutable instance of [CouponArchiveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .couponId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CouponArchiveParams = CouponArchiveParams( - checkRequired("couponId", couponId), + couponId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -211,7 +202,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> couponId + 0 -> couponId ?: "" else -> "" } 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 90f95717..2c7b8bf3 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 @@ -15,7 +15,6 @@ 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 @@ -162,43 +161,33 @@ private constructor( */ fun discount(discount: JsonField) = apply { body.discount(discount) } - /** - * Alias for calling [discount] with `Discount.ofNewCouponPercentage(newCouponPercentage)`. - */ - fun discount(newCouponPercentage: Discount.NewCouponPercentageDiscount) = apply { - body.discount(newCouponPercentage) - } + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + fun discount(percentage: Discount.Percentage) = apply { body.discount(percentage) } /** * Alias for calling [discount] with the following: * ```java - * Discount.NewCouponPercentageDiscount.builder() - * .discountType(CouponCreateParams.Discount.NewCouponPercentageDiscount.DiscountType.PERCENTAGE) + * Discount.Percentage.builder() * .percentageDiscount(percentageDiscount) * .build() * ``` */ - fun newCouponPercentageDiscount(percentageDiscount: Double) = apply { - body.newCouponPercentageDiscount(percentageDiscount) + fun percentageDiscount(percentageDiscount: Double) = apply { + body.percentageDiscount(percentageDiscount) } - /** Alias for calling [discount] with `Discount.ofNewCouponAmount(newCouponAmount)`. */ - fun discount(newCouponAmount: Discount.NewCouponAmountDiscount) = apply { - body.discount(newCouponAmount) - } + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + fun discount(amount: Discount.Amount) = apply { body.discount(amount) } /** * Alias for calling [discount] with the following: * ```java - * Discount.NewCouponAmountDiscount.builder() - * .discountType(CouponCreateParams.Discount.NewCouponAmountDiscount.DiscountType.AMOUNT) + * Discount.Amount.builder() * .amountDiscount(amountDiscount) * .build() * ``` */ - fun newCouponAmountDiscount(amountDiscount: String) = apply { - body.newCouponAmountDiscount(amountDiscount) - } + fun amountDiscount(amountDiscount: String) = apply { body.amountDiscount(amountDiscount) } /** This string can be used to redeem this coupon for a given subscription. */ fun redemptionCode(redemptionCode: String) = apply { body.redemptionCode(redemptionCode) } @@ -565,55 +554,36 @@ private constructor( */ fun discount(discount: JsonField) = apply { this.discount = discount } - /** - * Alias for calling [discount] with - * `Discount.ofNewCouponPercentage(newCouponPercentage)`. - */ - fun discount(newCouponPercentage: Discount.NewCouponPercentageDiscount) = - discount(Discount.ofNewCouponPercentage(newCouponPercentage)) + /** Alias for calling [discount] with `Discount.ofPercentage(percentage)`. */ + fun discount(percentage: Discount.Percentage) = + discount(Discount.ofPercentage(percentage)) /** * Alias for calling [discount] with the following: * ```java - * Discount.NewCouponPercentageDiscount.builder() - * .discountType(CouponCreateParams.Discount.NewCouponPercentageDiscount.DiscountType.PERCENTAGE) + * Discount.Percentage.builder() * .percentageDiscount(percentageDiscount) * .build() * ``` */ - fun newCouponPercentageDiscount(percentageDiscount: Double) = + fun percentageDiscount(percentageDiscount: Double) = discount( - Discount.NewCouponPercentageDiscount.builder() - .discountType( - CouponCreateParams.Discount.NewCouponPercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(percentageDiscount) - .build() + Discount.Percentage.builder().percentageDiscount(percentageDiscount).build() ) - /** Alias for calling [discount] with `Discount.ofNewCouponAmount(newCouponAmount)`. */ - fun discount(newCouponAmount: Discount.NewCouponAmountDiscount) = - discount(Discount.ofNewCouponAmount(newCouponAmount)) + /** Alias for calling [discount] with `Discount.ofAmount(amount)`. */ + fun discount(amount: Discount.Amount) = discount(Discount.ofAmount(amount)) /** * Alias for calling [discount] with the following: * ```java - * Discount.NewCouponAmountDiscount.builder() - * .discountType(CouponCreateParams.Discount.NewCouponAmountDiscount.DiscountType.AMOUNT) + * Discount.Amount.builder() * .amountDiscount(amountDiscount) * .build() * ``` */ - fun newCouponAmountDiscount(amountDiscount: String) = - discount( - Discount.NewCouponAmountDiscount.builder() - .discountType( - CouponCreateParams.Discount.NewCouponAmountDiscount.DiscountType.AMOUNT - ) - .amountDiscount(amountDiscount) - .build() - ) + fun amountDiscount(amountDiscount: String) = + discount(Discount.Amount.builder().amountDiscount(amountDiscount).build()) /** This string can be used to redeem this coupon for a given subscription. */ fun redemptionCode(redemptionCode: String) = @@ -790,33 +760,29 @@ private constructor( @JsonSerialize(using = Discount.Serializer::class) class Discount private constructor( - private val newCouponPercentage: NewCouponPercentageDiscount? = null, - private val newCouponAmount: NewCouponAmountDiscount? = null, + private val percentage: Percentage? = null, + private val amount: Amount? = null, private val _json: JsonValue? = null, ) { - fun newCouponPercentage(): Optional = - Optional.ofNullable(newCouponPercentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun newCouponAmount(): Optional = - Optional.ofNullable(newCouponAmount) + fun amount(): Optional = Optional.ofNullable(amount) - fun isNewCouponPercentage(): Boolean = newCouponPercentage != null + fun isPercentage(): Boolean = percentage != null - fun isNewCouponAmount(): Boolean = newCouponAmount != null + fun isAmount(): Boolean = amount != null - fun asNewCouponPercentage(): NewCouponPercentageDiscount = - newCouponPercentage.getOrThrow("newCouponPercentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asNewCouponAmount(): NewCouponAmountDiscount = - newCouponAmount.getOrThrow("newCouponAmount") + fun asAmount(): Amount = amount.getOrThrow("amount") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newCouponPercentage != null -> visitor.visitNewCouponPercentage(newCouponPercentage) - newCouponAmount != null -> visitor.visitNewCouponAmount(newCouponAmount) + percentage != null -> visitor.visitPercentage(percentage) + amount != null -> visitor.visitAmount(amount) else -> visitor.unknown(_json) } @@ -829,14 +795,12 @@ private constructor( accept( object : Visitor { - override fun visitNewCouponPercentage( - newCouponPercentage: NewCouponPercentageDiscount - ) { - newCouponPercentage.validate() + override fun visitPercentage(percentage: Percentage) { + percentage.validate() } - override fun visitNewCouponAmount(newCouponAmount: NewCouponAmountDiscount) { - newCouponAmount.validate() + override fun visitAmount(amount: Amount) { + amount.validate() } } ) @@ -861,12 +825,9 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewCouponPercentage( - newCouponPercentage: NewCouponPercentageDiscount - ) = newCouponPercentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitNewCouponAmount(newCouponAmount: NewCouponAmountDiscount) = - newCouponAmount.validity() + override fun visitAmount(amount: Amount) = amount.validity() override fun unknown(json: JsonValue?) = 0 } @@ -877,28 +838,24 @@ private constructor( return true } - return /* spotless:off */ other is Discount && newCouponPercentage == other.newCouponPercentage && newCouponAmount == other.newCouponAmount /* spotless:on */ + return /* spotless:off */ other is Discount && percentage == other.percentage && amount == other.amount /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newCouponPercentage, newCouponAmount) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentage, amount) /* spotless:on */ override fun toString(): String = when { - newCouponPercentage != null -> "Discount{newCouponPercentage=$newCouponPercentage}" - newCouponAmount != null -> "Discount{newCouponAmount=$newCouponAmount}" + percentage != null -> "Discount{percentage=$percentage}" + amount != null -> "Discount{amount=$amount}" _json != null -> "Discount{_unknown=$_json}" else -> throw IllegalStateException("Invalid Discount") } companion object { - @JvmStatic - fun ofNewCouponPercentage(newCouponPercentage: NewCouponPercentageDiscount) = - Discount(newCouponPercentage = newCouponPercentage) + @JvmStatic fun ofPercentage(percentage: Percentage) = Discount(percentage = percentage) - @JvmStatic - fun ofNewCouponAmount(newCouponAmount: NewCouponAmountDiscount) = - Discount(newCouponAmount = newCouponAmount) + @JvmStatic fun ofAmount(amount: Amount) = Discount(amount = amount) } /** @@ -906,9 +863,9 @@ private constructor( */ interface Visitor { - fun visitNewCouponPercentage(newCouponPercentage: NewCouponPercentageDiscount): T + fun visitPercentage(percentage: Percentage): T - fun visitNewCouponAmount(newCouponAmount: NewCouponAmountDiscount): T + fun visitAmount(amount: Amount): T /** * Maps an unknown variant of [Discount] to a value of type [T]. @@ -934,14 +891,14 @@ private constructor( when (discountType) { "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Discount(newCouponPercentage = it, _json = json) } - ?: Discount(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(percentage = it, _json = json) + } ?: Discount(_json = json) } "amount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Discount(newCouponAmount = it, _json = json) } - ?: Discount(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(amount = it, _json = json) + } ?: Discount(_json = json) } } @@ -957,18 +914,17 @@ private constructor( provider: SerializerProvider, ) { when { - value.newCouponPercentage != null -> - generator.writeObject(value.newCouponPercentage) - value.newCouponAmount != null -> generator.writeObject(value.newCouponAmount) + value.percentage != null -> generator.writeObject(value.percentage) + value.amount != null -> generator.writeObject(value.amount) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Discount") } } } - class NewCouponPercentageDiscount + class Percentage private constructor( - private val discountType: JsonField, + private val discountType: JsonValue, private val percentageDiscount: JsonField, private val additionalProperties: MutableMap, ) { @@ -977,18 +933,24 @@ private constructor( private constructor( @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("percentage_discount") @ExcludeMissing percentageDiscount: JsonField = JsonMissing.of(), ) : this(discountType, percentageDiscount, 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -997,16 +959,6 @@ private constructor( */ fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [percentageDiscount]. * @@ -1032,45 +984,43 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewCouponPercentageDiscount]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java - * .discountType() * .percentageDiscount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewCouponPercentageDiscount]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var percentageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newCouponPercentageDiscount: NewCouponPercentageDiscount) = - apply { - discountType = newCouponPercentageDiscount.discountType - percentageDiscount = newCouponPercentageDiscount.percentageDiscount - additionalProperties = - newCouponPercentageDiscount.additionalProperties.toMutableMap() - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) + internal fun from(percentage: Percentage) = apply { + discountType = percentage.discountType + percentageDiscount = percentage.percentageDiscount + additionalProperties = percentage.additionalProperties.toMutableMap() + } /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -1111,21 +1061,20 @@ private constructor( } /** - * Returns an immutable instance of [NewCouponPercentageDiscount]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .discountType() * .percentageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewCouponPercentageDiscount = - NewCouponPercentageDiscount( - checkRequired("discountType", discountType), + fun build(): Percentage = + Percentage( + discountType, checkRequired("percentageDiscount", percentageDiscount), additionalProperties.toMutableMap(), ) @@ -1133,12 +1082,16 @@ private constructor( private var validated: Boolean = false - fun validate(): NewCouponPercentageDiscount = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } percentageDiscount() validated = true } @@ -1159,142 +1112,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (percentageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewCouponPercentageDiscount && discountType == other.discountType && percentageDiscount == other.percentageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && discountType == other.discountType && percentageDiscount == other.percentageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1304,13 +1130,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewCouponPercentageDiscount{discountType=$discountType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + "Percentage{discountType=$discountType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" } - class NewCouponAmountDiscount + class Amount private constructor( private val amountDiscount: JsonField, - private val discountType: JsonField, + private val discountType: JsonValue, private val additionalProperties: MutableMap, ) { @@ -1321,7 +1147,7 @@ private constructor( amountDiscount: JsonField = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), ) : this(amountDiscount, discountType, mutableMapOf()) /** @@ -1332,11 +1158,17 @@ private constructor( fun amountDiscount(): String = amountDiscount.getRequired("amount_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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * Returns the raw JSON value of [amountDiscount]. @@ -1348,16 +1180,6 @@ private constructor( @ExcludeMissing fun _amountDiscount(): JsonField = amountDiscount - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1373,31 +1195,28 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewCouponAmountDiscount]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() - * .discountType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewCouponAmountDiscount]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newCouponAmountDiscount: NewCouponAmountDiscount) = apply { - amountDiscount = newCouponAmountDiscount.amountDiscount - discountType = newCouponAmountDiscount.discountType - additionalProperties = - newCouponAmountDiscount.additionalProperties.toMutableMap() + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + discountType = amount.discountType + additionalProperties = amount.additionalProperties.toMutableMap() } fun amountDiscount(amountDiscount: String) = @@ -1414,17 +1233,19 @@ private constructor( this.amountDiscount = amountDiscount } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -1451,35 +1272,38 @@ private constructor( } /** - * Returns an immutable instance of [NewCouponAmountDiscount]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .amountDiscount() - * .discountType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewCouponAmountDiscount = - NewCouponAmountDiscount( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), - checkRequired("discountType", discountType), + discountType, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): NewCouponAmountDiscount = apply { + fun validate(): Amount = apply { if (validated) { return@apply } amountDiscount() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } validated = true } @@ -1500,141 +1324,14 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amountDiscount.asKnown().isPresent) 1 else 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewCouponAmountDiscount && amountDiscount == other.amountDiscount && discountType == other.discountType && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && discountType == other.discountType && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -1644,7 +1341,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewCouponAmountDiscount{amountDiscount=$amountDiscount, discountType=$discountType, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, discountType=$discountType, additionalProperties=$additionalProperties}" } } 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 afb3aebc..9222e419 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption code, use the @@ -14,12 +15,12 @@ import java.util.Objects */ class CouponFetchParams private constructor( - private val couponId: String, + private val couponId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun couponId(): String = couponId + fun couponId(): Optional = Optional.ofNullable(couponId) fun _additionalHeaders(): Headers = additionalHeaders @@ -29,14 +30,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CouponFetchParams]. - * - * The following fields are required: - * ```java - * .couponId() - * ``` - */ + @JvmStatic fun none(): CouponFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CouponFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -54,7 +50,10 @@ private constructor( additionalQueryParams = couponFetchParams.additionalQueryParams.toBuilder() } - fun couponId(couponId: String) = apply { this.couponId = couponId } + fun couponId(couponId: String?) = apply { this.couponId = couponId } + + /** Alias for calling [Builder.couponId] with `couponId.orElse(null)`. */ + fun couponId(couponId: Optional) = couponId(couponId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -158,25 +157,14 @@ private constructor( * Returns an immutable instance of [CouponFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .couponId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CouponFetchParams = - CouponFetchParams( - checkRequired("couponId", couponId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + CouponFetchParams(couponId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> couponId + 0 -> couponId ?: "" else -> "" } 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 8fd79bed..54fa128c 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.CouponService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [CouponService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: CouponService, private val params: CouponListParams, private val response: CouponListPageResponse, -) { +) : Page { /** * Delegates to [CouponListPageResponse], but gracefully handles missing data. @@ -33,30 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CouponListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): CouponListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CouponListParams = params @@ -125,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CouponListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 6486b6da..884d7b62 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.CouponServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [CouponServiceAsync.list] */ class CouponListPageAsync private constructor( private val service: CouponServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CouponListParams, private val response: CouponListPageResponse, -) { +) : PageAsync { /** * Delegates to [CouponListPageResponse], but gracefully handles missing data. @@ -34,33 +36,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CouponListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CouponListParams = params @@ -78,6 +69,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -89,18 +81,24 @@ private constructor( class Builder internal constructor() { private var service: CouponServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CouponListParams? = null private var response: CouponListPageResponse? = null @JvmSynthetic internal fun from(couponListPageAsync: CouponListPageAsync) = apply { service = couponListPageAsync.service + streamHandlerExecutor = couponListPageAsync.streamHandlerExecutor params = couponListPageAsync.params response = couponListPageAsync.response } fun service(service: CouponServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CouponListParams) = apply { this.params = params } @@ -115,6 +113,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -124,47 +123,22 @@ private constructor( fun build(): CouponListPageAsync = CouponListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CouponListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Coupon) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CouponListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CouponListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CouponListPageAsync{service=$service, params=$params, response=$response}" + "CouponListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 77f17471..d81a7bb7 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.coupons.SubscriptionService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [SubscriptionService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: SubscriptionService, private val params: CouponSubscriptionListParams, private val response: Subscriptions, -) { +) : Page { /** * Delegates to [Subscriptions], but gracefully handles missing data. @@ -33,31 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CouponSubscriptionListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.list(it) } + override fun nextPage(): CouponSubscriptionListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CouponSubscriptionListParams = params @@ -126,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CouponSubscriptionListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 47417e21..afc24358 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [SubscriptionServiceAsync.list] */ class CouponSubscriptionListPageAsync private constructor( private val service: SubscriptionServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CouponSubscriptionListParams, private val response: Subscriptions, -) { +) : PageAsync { /** * Delegates to [Subscriptions], but gracefully handles missing data. @@ -34,33 +36,23 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CouponSubscriptionListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CouponSubscriptionListParams = params @@ -79,6 +71,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -90,6 +83,7 @@ private constructor( class Builder internal constructor() { private var service: SubscriptionServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CouponSubscriptionListParams? = null private var response: Subscriptions? = null @@ -97,12 +91,17 @@ private constructor( internal fun from(couponSubscriptionListPageAsync: CouponSubscriptionListPageAsync) = apply { service = couponSubscriptionListPageAsync.service + streamHandlerExecutor = couponSubscriptionListPageAsync.streamHandlerExecutor params = couponSubscriptionListPageAsync.params response = couponSubscriptionListPageAsync.response } fun service(service: SubscriptionServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CouponSubscriptionListParams) = apply { this.params = params } @@ -117,6 +116,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -126,47 +126,22 @@ private constructor( fun build(): CouponSubscriptionListPageAsync = CouponSubscriptionListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CouponSubscriptionListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Subscription) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CouponSubscriptionListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CouponSubscriptionListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CouponSubscriptionListPageAsync{service=$service, params=$params, response=$response}" + "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 a3b3be8d..6ed44a4f 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects @@ -18,14 +17,14 @@ import kotlin.jvm.optionals.getOrNull */ class CouponSubscriptionListParams private constructor( - private val couponId: String, + private val couponId: String?, private val cursor: String?, private val limit: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun couponId(): String = couponId + fun couponId(): Optional = Optional.ofNullable(couponId) /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the @@ -44,13 +43,10 @@ private constructor( companion object { + @JvmStatic fun none(): CouponSubscriptionListParams = builder().build() + /** * Returns a mutable builder for constructing an instance of [CouponSubscriptionListParams]. - * - * The following fields are required: - * ```java - * .couponId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -73,7 +69,10 @@ private constructor( additionalQueryParams = couponSubscriptionListParams.additionalQueryParams.toBuilder() } - fun couponId(couponId: String) = apply { this.couponId = couponId } + fun couponId(couponId: String?) = apply { this.couponId = couponId } + + /** Alias for calling [Builder.couponId] with `couponId.orElse(null)`. */ + fun couponId(couponId: Optional) = couponId(couponId.getOrNull()) /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the @@ -199,17 +198,10 @@ private constructor( * Returns an immutable instance of [CouponSubscriptionListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .couponId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CouponSubscriptionListParams = CouponSubscriptionListParams( - checkRequired("couponId", couponId), + couponId, cursor, limit, additionalHeaders.build(), @@ -219,7 +211,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> couponId + 0 -> couponId ?: "" else -> "" } 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 04c0d080..827792b4 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to fetch a single [`Credit Note`](/invoicing/credit-notes) given an @@ -14,12 +15,12 @@ import java.util.Objects */ class CreditNoteFetchParams private constructor( - private val creditNoteId: String, + private val creditNoteId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun creditNoteId(): String = creditNoteId + fun creditNoteId(): Optional = Optional.ofNullable(creditNoteId) fun _additionalHeaders(): Headers = additionalHeaders @@ -29,14 +30,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CreditNoteFetchParams]. - * - * The following fields are required: - * ```java - * .creditNoteId() - * ``` - */ + @JvmStatic fun none(): CreditNoteFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CreditNoteFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -54,7 +50,10 @@ private constructor( additionalQueryParams = creditNoteFetchParams.additionalQueryParams.toBuilder() } - fun creditNoteId(creditNoteId: String) = apply { this.creditNoteId = creditNoteId } + fun creditNoteId(creditNoteId: String?) = apply { this.creditNoteId = creditNoteId } + + /** Alias for calling [Builder.creditNoteId] with `creditNoteId.orElse(null)`. */ + fun creditNoteId(creditNoteId: Optional) = creditNoteId(creditNoteId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -158,17 +157,10 @@ private constructor( * Returns an immutable instance of [CreditNoteFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .creditNoteId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CreditNoteFetchParams = CreditNoteFetchParams( - checkRequired("creditNoteId", creditNoteId), + creditNoteId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -176,7 +168,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> creditNoteId + 0 -> creditNoteId ?: "" else -> "" } 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 cbbd4f40..a2337e3b 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.CreditNoteService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [CreditNoteService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: CreditNoteService, private val params: CreditNoteListParams, private val response: CreditNoteListPageResponse, -) { +) : Page { /** * Delegates to [CreditNoteListPageResponse], but gracefully handles missing data. @@ -33,30 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CreditNoteListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): CreditNoteListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CreditNoteListParams = params @@ -125,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CreditNoteListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 104920cc..3710fe7e 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.CreditNoteServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [CreditNoteServiceAsync.list] */ class CreditNoteListPageAsync private constructor( private val service: CreditNoteServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CreditNoteListParams, private val response: CreditNoteListPageResponse, -) { +) : PageAsync { /** * Delegates to [CreditNoteListPageResponse], but gracefully handles missing data. @@ -34,33 +36,23 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CreditNoteListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CreditNoteListParams = params @@ -78,6 +70,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -89,18 +82,24 @@ private constructor( class Builder internal constructor() { private var service: CreditNoteServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CreditNoteListParams? = null private var response: CreditNoteListPageResponse? = null @JvmSynthetic internal fun from(creditNoteListPageAsync: CreditNoteListPageAsync) = apply { service = creditNoteListPageAsync.service + streamHandlerExecutor = creditNoteListPageAsync.streamHandlerExecutor params = creditNoteListPageAsync.params response = creditNoteListPageAsync.response } fun service(service: CreditNoteServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CreditNoteListParams) = apply { this.params = params } @@ -115,6 +114,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -124,47 +124,22 @@ private constructor( fun build(): CreditNoteListPageAsync = CreditNoteListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CreditNoteListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (CreditNote) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CreditNoteListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CreditNoteListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CreditNoteListPageAsync{service=$service, params=$params, response=$response}" + "CreditNoteListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 e2658926..31b73445 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 @@ -27,13 +27,13 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerBalanceTransactionCreateParams private constructor( - private val customerId: String, + private val customerId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -92,7 +92,6 @@ private constructor( * * The following fields are required: * ```java - * .customerId() * .amount() * .type() * ``` @@ -119,7 +118,10 @@ private constructor( customerBalanceTransactionCreateParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) /** * Sets the entire request body. @@ -291,7 +293,6 @@ private constructor( * * The following fields are required: * ```java - * .customerId() * .amount() * .type() * ``` @@ -300,7 +301,7 @@ private constructor( */ fun build(): CustomerBalanceTransactionCreateParams = CustomerBalanceTransactionCreateParams( - checkRequired("customerId", customerId), + customerId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -311,7 +312,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 a313acd6..73d8e3bc 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.BalanceTransactionService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [BalanceTransactionService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: BalanceTransactionService, private val params: CustomerBalanceTransactionListParams, private val response: CustomerBalanceTransactionListPageResponse, -) { +) : Page { /** * Delegates to [CustomerBalanceTransactionListPageResponse], but gracefully handles missing @@ -36,31 +36,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerBalanceTransactionListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.list(it) } + override fun nextPage(): CustomerBalanceTransactionListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CustomerBalanceTransactionListParams = params @@ -133,26 +124,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CustomerBalanceTransactionListPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 6214987f..56c745f8 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.BalanceTransactionServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [BalanceTransactionServiceAsync.list] */ class CustomerBalanceTransactionListPageAsync private constructor( private val service: BalanceTransactionServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CustomerBalanceTransactionListParams, private val response: CustomerBalanceTransactionListPageResponse, -) { +) : PageAsync { /** * Delegates to [CustomerBalanceTransactionListPageResponse], but gracefully handles missing @@ -37,33 +39,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerBalanceTransactionListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CustomerBalanceTransactionListParams = params @@ -82,6 +75,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -93,6 +87,7 @@ private constructor( class Builder internal constructor() { private var service: BalanceTransactionServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CustomerBalanceTransactionListParams? = null private var response: CustomerBalanceTransactionListPageResponse? = null @@ -101,12 +96,17 @@ private constructor( customerBalanceTransactionListPageAsync: CustomerBalanceTransactionListPageAsync ) = apply { service = customerBalanceTransactionListPageAsync.service + streamHandlerExecutor = customerBalanceTransactionListPageAsync.streamHandlerExecutor params = customerBalanceTransactionListPageAsync.params response = customerBalanceTransactionListPageAsync.response } fun service(service: BalanceTransactionServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CustomerBalanceTransactionListParams) = apply { this.params = params } @@ -123,6 +123,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -132,52 +133,22 @@ private constructor( fun build(): CustomerBalanceTransactionListPageAsync = CustomerBalanceTransactionListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CustomerBalanceTransactionListPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (CustomerBalanceTransactionListResponse) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList( - executor: Executor - ): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerBalanceTransactionListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CustomerBalanceTransactionListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CustomerBalanceTransactionListPageAsync{service=$service, params=$params, response=$response}" + "CustomerBalanceTransactionListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 f1364f6a..52a4bc00 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.time.OffsetDateTime @@ -40,7 +39,7 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerBalanceTransactionListParams private constructor( - private val customerId: String, + private val customerId: String?, private val cursor: String?, private val limit: Long?, private val operationTimeGt: OffsetDateTime?, @@ -51,7 +50,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the @@ -78,14 +77,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerBalanceTransactionListParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerBalanceTransactionListParams]. - * - * The following fields are required: - * ```java - * .customerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -119,7 +115,10 @@ private constructor( customerBalanceTransactionListParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the @@ -277,17 +276,10 @@ private constructor( * Returns an immutable instance of [CustomerBalanceTransactionListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerBalanceTransactionListParams = CustomerBalanceTransactionListParams( - checkRequired("customerId", customerId), + customerId, cursor, limit, operationTimeGt, @@ -301,7 +293,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 fd63e2d1..174a94c4 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 @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException @@ -126,7 +125,7 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCostListByExternalIdParams private constructor( - private val externalCustomerId: String, + private val externalCustomerId: String?, private val currency: String?, private val timeframeEnd: OffsetDateTime?, private val timeframeStart: OffsetDateTime?, @@ -135,7 +134,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun externalCustomerId(): String = externalCustomerId + fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) /** The currency or custom pricing unit to use. */ fun currency(): Optional = Optional.ofNullable(currency) @@ -161,14 +160,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerCostListByExternalIdParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerCostListByExternalIdParams]. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -197,10 +193,16 @@ private constructor( customerCostListByExternalIdParams.additionalQueryParams.toBuilder() } - fun externalCustomerId(externalCustomerId: String) = apply { + fun externalCustomerId(externalCustomerId: String?) = apply { this.externalCustomerId = externalCustomerId } + /** + * Alias for calling [Builder.externalCustomerId] with `externalCustomerId.orElse(null)`. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.getOrNull()) + /** The currency or custom pricing unit to use. */ fun currency(currency: String?) = apply { this.currency = currency } @@ -335,17 +337,10 @@ private constructor( * Returns an immutable instance of [CustomerCostListByExternalIdParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerCostListByExternalIdParams = CustomerCostListByExternalIdParams( - checkRequired("externalCustomerId", externalCustomerId), + externalCustomerId, currency, timeframeEnd, timeframeStart, @@ -357,7 +352,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalCustomerId + 0 -> externalCustomerId ?: "" else -> "" } 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 12365755..dc76df2c 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 @@ -657,156 +657,154 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = - price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with * `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** The price the cost is associated with */ 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 75f29da0..2fbc742a 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 @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException @@ -126,7 +125,7 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCostListParams private constructor( - private val customerId: String, + private val customerId: String?, private val currency: String?, private val timeframeEnd: OffsetDateTime?, private val timeframeStart: OffsetDateTime?, @@ -135,7 +134,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) /** The currency or custom pricing unit to use. */ fun currency(): Optional = Optional.ofNullable(currency) @@ -161,14 +160,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CustomerCostListParams]. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - */ + @JvmStatic fun none(): CustomerCostListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CustomerCostListParams]. */ @JvmStatic fun builder() = Builder() } @@ -194,7 +188,10 @@ private constructor( additionalQueryParams = customerCostListParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) /** The currency or custom pricing unit to use. */ fun currency(currency: String?) = apply { this.currency = currency } @@ -330,17 +327,10 @@ private constructor( * Returns an immutable instance of [CustomerCostListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerCostListParams = CustomerCostListParams( - checkRequired("customerId", customerId), + customerId, currency, timeframeEnd, timeframeStart, @@ -352,7 +342,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 584c4318..ad7f6950 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 @@ -653,156 +653,154 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = - price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with * `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** The price the cost is associated with */ 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 c6d81bff..8f0bb93b 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 @@ -822,42 +822,38 @@ private constructor( body.taxConfiguration(taxConfiguration) } - /** - * Alias for calling [taxConfiguration] with `TaxConfiguration.ofNewAvalara(newAvalara)`. - */ - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = apply { - body.taxConfiguration(newAvalara) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAvalara(avalara)`. */ + fun taxConfiguration(avalara: TaxConfiguration.Avalara) = apply { + body.taxConfiguration(avalara) } /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewAvalaraTaxConfiguration.builder() - * .taxProvider(CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + * TaxConfiguration.Avalara.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = apply { - body.newAvalaraTaxConfiguration(taxExempt) + fun avalaraTaxConfiguration(taxExempt: Boolean) = apply { + body.avalaraTaxConfiguration(taxExempt) } - /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofNewTaxJar(newTaxJar)`. */ - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = apply { - body.taxConfiguration(newTaxJar) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofTaxjar(taxjar)`. */ + fun taxConfiguration(taxjar: TaxConfiguration.Taxjar) = apply { + body.taxConfiguration(taxjar) } /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewTaxJarConfiguration.builder() - * .taxProvider(CustomerCreateParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider.TAXJAR) + * TaxConfiguration.Taxjar.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = apply { - body.newTaxJarTaxConfiguration(taxExempt) + fun taxjarTaxConfiguration(taxExempt: Boolean) = apply { + body.taxjarTaxConfiguration(taxExempt) } /** @@ -2070,59 +2066,35 @@ private constructor( this.taxConfiguration = taxConfiguration } - /** - * Alias for calling [taxConfiguration] with - * `TaxConfiguration.ofNewAvalara(newAvalara)`. - */ - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = - taxConfiguration(TaxConfiguration.ofNewAvalara(newAvalara)) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAvalara(avalara)`. */ + fun taxConfiguration(avalara: TaxConfiguration.Avalara) = + taxConfiguration(TaxConfiguration.ofAvalara(avalara)) /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewAvalaraTaxConfiguration.builder() - * .taxProvider(CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + * TaxConfiguration.Avalara.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExempt(taxExempt) - .build() - ) + fun avalaraTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Avalara.builder().taxExempt(taxExempt).build()) - /** - * Alias for calling [taxConfiguration] with `TaxConfiguration.ofNewTaxJar(newTaxJar)`. - */ - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = - taxConfiguration(TaxConfiguration.ofNewTaxJar(newTaxJar)) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofTaxjar(taxjar)`. */ + fun taxConfiguration(taxjar: TaxConfiguration.Taxjar) = + taxConfiguration(TaxConfiguration.ofTaxjar(taxjar)) /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewTaxJarConfiguration.builder() - * .taxProvider(CustomerCreateParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider.TAXJAR) + * TaxConfiguration.Taxjar.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewTaxJarConfiguration.builder() - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider - .TAXJAR - ) - .taxExempt(taxExempt) - .build() - ) + fun taxjarTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Taxjar.builder().taxExempt(taxExempt).build()) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -4111,29 +4083,29 @@ private constructor( @JsonSerialize(using = TaxConfiguration.Serializer::class) class TaxConfiguration private constructor( - private val newAvalara: NewAvalaraTaxConfiguration? = null, - private val newTaxJar: NewTaxJarConfiguration? = null, + private val avalara: Avalara? = null, + private val taxjar: Taxjar? = null, private val _json: JsonValue? = null, ) { - fun newAvalara(): Optional = Optional.ofNullable(newAvalara) + fun avalara(): Optional = Optional.ofNullable(avalara) - fun newTaxJar(): Optional = Optional.ofNullable(newTaxJar) + fun taxjar(): Optional = Optional.ofNullable(taxjar) - fun isNewAvalara(): Boolean = newAvalara != null + fun isAvalara(): Boolean = avalara != null - fun isNewTaxJar(): Boolean = newTaxJar != null + fun isTaxjar(): Boolean = taxjar != null - fun asNewAvalara(): NewAvalaraTaxConfiguration = newAvalara.getOrThrow("newAvalara") + fun asAvalara(): Avalara = avalara.getOrThrow("avalara") - fun asNewTaxJar(): NewTaxJarConfiguration = newTaxJar.getOrThrow("newTaxJar") + fun asTaxjar(): Taxjar = taxjar.getOrThrow("taxjar") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newAvalara != null -> visitor.visitNewAvalara(newAvalara) - newTaxJar != null -> visitor.visitNewTaxJar(newTaxJar) + avalara != null -> visitor.visitAvalara(avalara) + taxjar != null -> visitor.visitTaxjar(taxjar) else -> visitor.unknown(_json) } @@ -4146,12 +4118,12 @@ private constructor( accept( object : Visitor { - override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) { - newAvalara.validate() + override fun visitAvalara(avalara: Avalara) { + avalara.validate() } - override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) { - newTaxJar.validate() + override fun visitTaxjar(taxjar: Taxjar) { + taxjar.validate() } } ) @@ -4176,11 +4148,9 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = - newAvalara.validity() + override fun visitAvalara(avalara: Avalara) = avalara.validity() - override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) = - newTaxJar.validity() + override fun visitTaxjar(taxjar: Taxjar) = taxjar.validity() override fun unknown(json: JsonValue?) = 0 } @@ -4191,28 +4161,24 @@ private constructor( return true } - return /* spotless:off */ other is TaxConfiguration && newAvalara == other.newAvalara && newTaxJar == other.newTaxJar /* spotless:on */ + return /* spotless:off */ other is TaxConfiguration && avalara == other.avalara && taxjar == other.taxjar /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newAvalara, newTaxJar) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalara, taxjar) /* spotless:on */ override fun toString(): String = when { - newAvalara != null -> "TaxConfiguration{newAvalara=$newAvalara}" - newTaxJar != null -> "TaxConfiguration{newTaxJar=$newTaxJar}" + avalara != null -> "TaxConfiguration{avalara=$avalara}" + taxjar != null -> "TaxConfiguration{taxjar=$taxjar}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } companion object { - @JvmStatic - fun ofNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = - TaxConfiguration(newAvalara = newAvalara) + @JvmStatic fun ofAvalara(avalara: Avalara) = TaxConfiguration(avalara = avalara) - @JvmStatic - fun ofNewTaxJar(newTaxJar: NewTaxJarConfiguration) = - TaxConfiguration(newTaxJar = newTaxJar) + @JvmStatic fun ofTaxjar(taxjar: Taxjar) = TaxConfiguration(taxjar = taxjar) } /** @@ -4221,9 +4187,9 @@ private constructor( */ interface Visitor { - fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration): T + fun visitAvalara(avalara: Avalara): T - fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration): T + fun visitTaxjar(taxjar: Taxjar): T /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. @@ -4249,13 +4215,13 @@ private constructor( when (taxProvider) { "avalara" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { TaxConfiguration(newAvalara = it, _json = json) } - ?: TaxConfiguration(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(avalara = it, _json = json) + } ?: TaxConfiguration(_json = json) } "taxjar" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - TaxConfiguration(newTaxJar = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(taxjar = it, _json = json) } ?: TaxConfiguration(_json = json) } } @@ -4272,18 +4238,18 @@ private constructor( provider: SerializerProvider, ) { when { - value.newAvalara != null -> generator.writeObject(value.newAvalara) - value.newTaxJar != null -> generator.writeObject(value.newTaxJar) + value.avalara != null -> generator.writeObject(value.avalara) + value.taxjar != null -> generator.writeObject(value.taxjar) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } } } - class NewAvalaraTaxConfiguration + class Avalara private constructor( private val taxExempt: JsonField, - private val taxProvider: JsonField, + private val taxProvider: JsonValue, private val taxExemptionCode: JsonField, private val additionalProperties: MutableMap, ) { @@ -4295,7 +4261,7 @@ private constructor( taxExempt: JsonField = JsonMissing.of(), @JsonProperty("tax_provider") @ExcludeMissing - taxProvider: JsonField = JsonMissing.of(), + taxProvider: JsonValue = JsonMissing.of(), @JsonProperty("tax_exemption_code") @ExcludeMissing taxExemptionCode: JsonField = JsonMissing.of(), @@ -4309,11 +4275,17 @@ private constructor( fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("avalara") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -4332,16 +4304,6 @@ private constructor( @ExcludeMissing fun _taxExempt(): JsonField = taxExempt - /** - * Returns the raw JSON value of [taxProvider]. - * - * Unlike [taxProvider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - /** * Returns the raw JSON value of [taxExemptionCode]. * @@ -4367,33 +4329,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewAvalaraTaxConfiguration]. + * Returns a mutable builder for constructing an instance of [Avalara]. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewAvalaraTaxConfiguration]. */ + /** A builder for [Avalara]. */ class Builder internal constructor() { private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("avalara") private var taxExemptionCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newAvalaraTaxConfiguration: NewAvalaraTaxConfiguration) = apply { - taxExempt = newAvalaraTaxConfiguration.taxExempt - taxProvider = newAvalaraTaxConfiguration.taxProvider - taxExemptionCode = newAvalaraTaxConfiguration.taxExemptionCode - additionalProperties = - newAvalaraTaxConfiguration.additionalProperties.toMutableMap() + internal fun from(avalara: Avalara) = apply { + taxExempt = avalara.taxExempt + taxProvider = avalara.taxProvider + taxExemptionCode = avalara.taxExemptionCode + additionalProperties = avalara.additionalProperties.toMutableMap() } fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) @@ -4407,18 +4366,19 @@ private constructor( */ fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - /** - * Sets [Builder.taxProvider] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.taxProvider] with a well-typed [TaxProvider] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("avalara") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } fun taxExemptionCode(taxExemptionCode: String?) = taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) @@ -4464,22 +4424,21 @@ private constructor( } /** - * Returns an immutable instance of [NewAvalaraTaxConfiguration]. + * Returns an immutable instance of [Avalara]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewAvalaraTaxConfiguration = - NewAvalaraTaxConfiguration( + fun build(): Avalara = + Avalara( checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), + taxProvider, taxExemptionCode, additionalProperties.toMutableMap(), ) @@ -4487,13 +4446,17 @@ private constructor( private var validated: Boolean = false - fun validate(): NewAvalaraTaxConfiguration = apply { + fun validate(): Avalara = apply { if (validated) { return@apply } taxExempt() - taxProvider().validate() + _taxProvider().let { + if (it != JsonValue.from("avalara")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } taxExemptionCode() validated = true } @@ -4515,141 +4478,15 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (taxExempt.asKnown().isPresent) 1 else 0) + - (taxProvider.asKnown().getOrNull()?.validity() ?: 0) + + taxProvider.let { if (it == JsonValue.from("avalara")) 1 else 0 } + (if (taxExemptionCode.asKnown().isPresent) 1 else 0) - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AVALARA = of("avalara") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - AVALARA - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AVALARA, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AVALARA -> Value.AVALARA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AVALARA -> Known.AVALARA - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): TaxProvider = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewAvalaraTaxConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Avalara && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4659,13 +4496,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAvalaraTaxConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" + "Avalara{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" } - class NewTaxJarConfiguration + class Taxjar private constructor( private val taxExempt: JsonField, - private val taxProvider: JsonField, + private val taxProvider: JsonValue, private val additionalProperties: MutableMap, ) { @@ -4676,7 +4513,7 @@ private constructor( taxExempt: JsonField = JsonMissing.of(), @JsonProperty("tax_provider") @ExcludeMissing - taxProvider: JsonField = JsonMissing.of(), + taxProvider: JsonValue = JsonMissing.of(), ) : this(taxExempt, taxProvider, mutableMapOf()) /** @@ -4687,11 +4524,17 @@ private constructor( fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("taxjar") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider /** * Returns the raw JSON value of [taxExempt]. @@ -4703,16 +4546,6 @@ private constructor( @ExcludeMissing fun _taxExempt(): JsonField = taxExempt - /** - * Returns the raw JSON value of [taxProvider]. - * - * Unlike [taxProvider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4728,31 +4561,28 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewTaxJarConfiguration]. + * Returns a mutable builder for constructing an instance of [Taxjar]. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewTaxJarConfiguration]. */ + /** A builder for [Taxjar]. */ class Builder internal constructor() { private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("taxjar") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newTaxJarConfiguration: NewTaxJarConfiguration) = apply { - taxExempt = newTaxJarConfiguration.taxExempt - taxProvider = newTaxJarConfiguration.taxProvider - additionalProperties = - newTaxJarConfiguration.additionalProperties.toMutableMap() + internal fun from(taxjar: Taxjar) = apply { + taxExempt = taxjar.taxExempt + taxProvider = taxjar.taxProvider + additionalProperties = taxjar.additionalProperties.toMutableMap() } fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) @@ -4766,18 +4596,19 @@ private constructor( */ fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - /** - * Sets [Builder.taxProvider] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.taxProvider] with a well-typed [TaxProvider] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("taxjar") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4802,35 +4633,38 @@ private constructor( } /** - * Returns an immutable instance of [NewTaxJarConfiguration]. + * Returns an immutable instance of [Taxjar]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewTaxJarConfiguration = - NewTaxJarConfiguration( + fun build(): Taxjar = + Taxjar( checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), + taxProvider, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): NewTaxJarConfiguration = apply { + fun validate(): Taxjar = apply { if (validated) { return@apply } taxExempt() - taxProvider().validate() + _taxProvider().let { + if (it != JsonValue.from("taxjar")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } validated = true } @@ -4851,140 +4685,14 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (taxExempt.asKnown().isPresent) 1 else 0) + - (taxProvider.asKnown().getOrNull()?.validity() ?: 0) - - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 TAXJAR = of("taxjar") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - TAXJAR - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAXJAR, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAXJAR -> Value.TAXJAR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TAXJAR -> Known.TAXJAR - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): TaxProvider = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + taxProvider.let { if (it == JsonValue.from("taxjar")) 1 else 0 } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewTaxJarConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Taxjar && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4994,7 +4702,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewTaxJarConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + "Taxjar{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" } } 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 77e0bcc2..2bf2a5ed 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 @@ -138,13 +138,13 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCreditLedgerCreateEntryByExternalIdParams private constructor( - private val externalCustomerId: String, + private val externalCustomerId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun externalCustomerId(): String = externalCustomerId + fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) fun body(): Body = body @@ -162,7 +162,6 @@ private constructor( * * The following fields are required: * ```java - * .externalCustomerId() * .body() * ``` */ @@ -191,122 +190,53 @@ private constructor( customerCreditLedgerCreateEntryByExternalIdParams.additionalQueryParams.toBuilder() } - fun externalCustomerId(externalCustomerId: String) = apply { + fun externalCustomerId(externalCustomerId: String?) = apply { this.externalCustomerId = externalCustomerId } - fun body(body: Body) = apply { this.body = body } - /** - * Alias for calling [body] with - * `Body.ofAddIncrementCreditLedgerEntryRequestParams(addIncrementCreditLedgerEntryRequestParams)`. + * Alias for calling [Builder.externalCustomerId] with `externalCustomerId.orElse(null)`. */ - fun body( - addIncrementCreditLedgerEntryRequestParams: - Body.AddIncrementCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams - ) - ) + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.getOrNull()) + + fun body(body: Body) = apply { this.body = body } + + /** Alias for calling [body] with `Body.ofIncrement(increment)`. */ + fun body(increment: Body.Increment) = body(Body.ofIncrement(increment)) /** * Alias for calling [body] with the following: * ```java - * Body.AddIncrementCreditLedgerEntryRequestParams.builder() - * .entryType(CustomerCreditLedgerCreateEntryByExternalIdParams.Body.AddIncrementCreditLedgerEntryRequestParams.EntryType.INCREMENT) + * Body.Increment.builder() * .amount(amount) * .build() * ``` */ - fun addIncrementCreditLedgerEntryRequestParamsBody(amount: Double) = - body( - Body.AddIncrementCreditLedgerEntryRequestParams.builder() - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .amount(amount) - .build() - ) + fun incrementBody(amount: Double) = body(Body.Increment.builder().amount(amount).build()) - /** - * Alias for calling [body] with - * `Body.ofAddDecrementCreditLedgerEntryRequestParams(addDecrementCreditLedgerEntryRequestParams)`. - */ - fun body( - addDecrementCreditLedgerEntryRequestParams: - Body.AddDecrementCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams - ) - ) + /** Alias for calling [body] with `Body.ofDecrement(decrement)`. */ + fun body(decrement: Body.Decrement) = body(Body.ofDecrement(decrement)) /** * Alias for calling [body] with the following: * ```java - * Body.AddDecrementCreditLedgerEntryRequestParams.builder() - * .entryType(CustomerCreditLedgerCreateEntryByExternalIdParams.Body.AddDecrementCreditLedgerEntryRequestParams.EntryType.DECREMENT) + * Body.Decrement.builder() * .amount(amount) * .build() * ``` */ - fun addDecrementCreditLedgerEntryRequestParamsBody(amount: Double) = - body( - Body.AddDecrementCreditLedgerEntryRequestParams.builder() - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddDecrementCreditLedgerEntryRequestParams - .EntryType - .DECREMENT - ) - .amount(amount) - .build() - ) + fun decrementBody(amount: Double) = body(Body.Decrement.builder().amount(amount).build()) - /** - * Alias for calling [body] with - * `Body.ofAddExpirationChangeCreditLedgerEntryRequestParams(addExpirationChangeCreditLedgerEntryRequestParams)`. - */ - fun body( - addExpirationChangeCreditLedgerEntryRequestParams: - Body.AddExpirationChangeCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams - ) - ) + /** Alias for calling [body] with `Body.ofExpirationChange(expirationChange)`. */ + fun body(expirationChange: Body.ExpirationChange) = + body(Body.ofExpirationChange(expirationChange)) - /** - * Alias for calling [body] with - * `Body.ofAddVoidCreditLedgerEntryRequestParams(addVoidCreditLedgerEntryRequestParams)`. - */ - fun body( - addVoidCreditLedgerEntryRequestParams: Body.AddVoidCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddVoidCreditLedgerEntryRequestParams(addVoidCreditLedgerEntryRequestParams) - ) + /** Alias for calling [body] with `Body.ofVoid(void_)`. */ + fun body(void_: Body.Void) = body(Body.ofVoid(void_)) - /** - * Alias for calling [body] with - * `Body.ofAddAmendmentCreditLedgerEntryRequestParams(addAmendmentCreditLedgerEntryRequestParams)`. - */ - fun body( - addAmendmentCreditLedgerEntryRequestParams: - Body.AddAmendmentCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams - ) - ) + /** Alias for calling [body] with `Body.ofAmendment(amendment)`. */ + fun body(amendment: Body.Amendment) = body(Body.ofAmendment(amendment)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -413,7 +343,6 @@ private constructor( * * The following fields are required: * ```java - * .externalCustomerId() * .body() * ``` * @@ -421,7 +350,7 @@ private constructor( */ fun build(): CustomerCreditLedgerCreateEntryByExternalIdParams = CustomerCreditLedgerCreateEntryByExternalIdParams( - checkRequired("externalCustomerId", externalCustomerId), + externalCustomerId, checkRequired("body", body), additionalHeaders.build(), additionalQueryParams.build(), @@ -432,7 +361,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalCustomerId + 0 -> externalCustomerId ?: "" else -> "" } @@ -444,111 +373,53 @@ private constructor( @JsonSerialize(using = Body.Serializer::class) class Body private constructor( - private val addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams? = - null, - private val addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams? = - null, - private val addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams? = - null, - private val addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams? = - null, - private val addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams? = - null, + private val increment: Increment? = null, + private val decrement: Decrement? = null, + private val expirationChange: ExpirationChange? = null, + private val void_: Void? = null, + private val amendment: Amendment? = null, private val _json: JsonValue? = null, ) { - fun addIncrementCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addIncrementCreditLedgerEntryRequestParams) + fun increment(): Optional = Optional.ofNullable(increment) - fun addDecrementCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addDecrementCreditLedgerEntryRequestParams) + fun decrement(): Optional = Optional.ofNullable(decrement) - fun addExpirationChangeCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addExpirationChangeCreditLedgerEntryRequestParams) + fun expirationChange(): Optional = Optional.ofNullable(expirationChange) - fun addVoidCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addVoidCreditLedgerEntryRequestParams) + fun void_(): Optional = Optional.ofNullable(void_) - fun addAmendmentCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addAmendmentCreditLedgerEntryRequestParams) + fun amendment(): Optional = Optional.ofNullable(amendment) - fun isAddIncrementCreditLedgerEntryRequestParams(): Boolean = - addIncrementCreditLedgerEntryRequestParams != null + fun isIncrement(): Boolean = increment != null - fun isAddDecrementCreditLedgerEntryRequestParams(): Boolean = - addDecrementCreditLedgerEntryRequestParams != null + fun isDecrement(): Boolean = decrement != null - fun isAddExpirationChangeCreditLedgerEntryRequestParams(): Boolean = - addExpirationChangeCreditLedgerEntryRequestParams != null + fun isExpirationChange(): Boolean = expirationChange != null - fun isAddVoidCreditLedgerEntryRequestParams(): Boolean = - addVoidCreditLedgerEntryRequestParams != null + fun isVoid(): Boolean = void_ != null - fun isAddAmendmentCreditLedgerEntryRequestParams(): Boolean = - addAmendmentCreditLedgerEntryRequestParams != null + fun isAmendment(): Boolean = amendment != null - fun asAddIncrementCreditLedgerEntryRequestParams(): - AddIncrementCreditLedgerEntryRequestParams = - addIncrementCreditLedgerEntryRequestParams.getOrThrow( - "addIncrementCreditLedgerEntryRequestParams" - ) + fun asIncrement(): Increment = increment.getOrThrow("increment") - fun asAddDecrementCreditLedgerEntryRequestParams(): - AddDecrementCreditLedgerEntryRequestParams = - addDecrementCreditLedgerEntryRequestParams.getOrThrow( - "addDecrementCreditLedgerEntryRequestParams" - ) + fun asDecrement(): Decrement = decrement.getOrThrow("decrement") - fun asAddExpirationChangeCreditLedgerEntryRequestParams(): - AddExpirationChangeCreditLedgerEntryRequestParams = - addExpirationChangeCreditLedgerEntryRequestParams.getOrThrow( - "addExpirationChangeCreditLedgerEntryRequestParams" - ) + fun asExpirationChange(): ExpirationChange = expirationChange.getOrThrow("expirationChange") - fun asAddVoidCreditLedgerEntryRequestParams(): AddVoidCreditLedgerEntryRequestParams = - addVoidCreditLedgerEntryRequestParams.getOrThrow( - "addVoidCreditLedgerEntryRequestParams" - ) + fun asVoid(): Void = void_.getOrThrow("void_") - fun asAddAmendmentCreditLedgerEntryRequestParams(): - AddAmendmentCreditLedgerEntryRequestParams = - addAmendmentCreditLedgerEntryRequestParams.getOrThrow( - "addAmendmentCreditLedgerEntryRequestParams" - ) + fun asAmendment(): Amendment = amendment.getOrThrow("amendment") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - addIncrementCreditLedgerEntryRequestParams != null -> - visitor.visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams - ) - addDecrementCreditLedgerEntryRequestParams != null -> - visitor.visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams - ) - addExpirationChangeCreditLedgerEntryRequestParams != null -> - visitor.visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams - ) - addVoidCreditLedgerEntryRequestParams != null -> - visitor.visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams - ) - addAmendmentCreditLedgerEntryRequestParams != null -> - visitor.visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams - ) + increment != null -> visitor.visitIncrement(increment) + decrement != null -> visitor.visitDecrement(decrement) + expirationChange != null -> visitor.visitExpirationChange(expirationChange) + void_ != null -> visitor.visitVoid(void_) + amendment != null -> visitor.visitAmendment(amendment) else -> visitor.unknown(_json) } @@ -561,38 +432,24 @@ private constructor( accept( object : Visitor { - override fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) { - addIncrementCreditLedgerEntryRequestParams.validate() + override fun visitIncrement(increment: Increment) { + increment.validate() } - override fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) { - addDecrementCreditLedgerEntryRequestParams.validate() + override fun visitDecrement(decrement: Decrement) { + decrement.validate() } - override fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) { - addExpirationChangeCreditLedgerEntryRequestParams.validate() + override fun visitExpirationChange(expirationChange: ExpirationChange) { + expirationChange.validate() } - override fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) { - addVoidCreditLedgerEntryRequestParams.validate() + override fun visitVoid(void_: Void) { + void_.validate() } - override fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) { - addAmendmentCreditLedgerEntryRequestParams.validate() + override fun visitAmendment(amendment: Amendment) { + amendment.validate() } } ) @@ -617,29 +474,16 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = addIncrementCreditLedgerEntryRequestParams.validity() - - override fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = addDecrementCreditLedgerEntryRequestParams.validity() - - override fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = addExpirationChangeCreditLedgerEntryRequestParams.validity() - - override fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = addVoidCreditLedgerEntryRequestParams.validity() - - override fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = addAmendmentCreditLedgerEntryRequestParams.validity() + override fun visitIncrement(increment: Increment) = increment.validity() + + override fun visitDecrement(decrement: Decrement) = decrement.validity() + + override fun visitExpirationChange(expirationChange: ExpirationChange) = + expirationChange.validity() + + override fun visitVoid(void_: Void) = void_.validity() + + override fun visitAmendment(amendment: Amendment) = amendment.validity() override fun unknown(json: JsonValue?) = 0 } @@ -650,101 +494,49 @@ private constructor( return true } - return /* spotless:off */ other is Body && addIncrementCreditLedgerEntryRequestParams == other.addIncrementCreditLedgerEntryRequestParams && addDecrementCreditLedgerEntryRequestParams == other.addDecrementCreditLedgerEntryRequestParams && addExpirationChangeCreditLedgerEntryRequestParams == other.addExpirationChangeCreditLedgerEntryRequestParams && addVoidCreditLedgerEntryRequestParams == other.addVoidCreditLedgerEntryRequestParams && addAmendmentCreditLedgerEntryRequestParams == other.addAmendmentCreditLedgerEntryRequestParams /* spotless:on */ + return /* spotless:off */ other is Body && increment == other.increment && decrement == other.decrement && expirationChange == other.expirationChange && void_ == other.void_ && amendment == other.amendment /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(addIncrementCreditLedgerEntryRequestParams, addDecrementCreditLedgerEntryRequestParams, addExpirationChangeCreditLedgerEntryRequestParams, addVoidCreditLedgerEntryRequestParams, addAmendmentCreditLedgerEntryRequestParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, void_, amendment) /* spotless:on */ override fun toString(): String = when { - addIncrementCreditLedgerEntryRequestParams != null -> - "Body{addIncrementCreditLedgerEntryRequestParams=$addIncrementCreditLedgerEntryRequestParams}" - addDecrementCreditLedgerEntryRequestParams != null -> - "Body{addDecrementCreditLedgerEntryRequestParams=$addDecrementCreditLedgerEntryRequestParams}" - addExpirationChangeCreditLedgerEntryRequestParams != null -> - "Body{addExpirationChangeCreditLedgerEntryRequestParams=$addExpirationChangeCreditLedgerEntryRequestParams}" - addVoidCreditLedgerEntryRequestParams != null -> - "Body{addVoidCreditLedgerEntryRequestParams=$addVoidCreditLedgerEntryRequestParams}" - addAmendmentCreditLedgerEntryRequestParams != null -> - "Body{addAmendmentCreditLedgerEntryRequestParams=$addAmendmentCreditLedgerEntryRequestParams}" + increment != null -> "Body{increment=$increment}" + decrement != null -> "Body{decrement=$decrement}" + expirationChange != null -> "Body{expirationChange=$expirationChange}" + void_ != null -> "Body{void_=$void_}" + amendment != null -> "Body{amendment=$amendment}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") } companion object { - @JvmStatic - fun ofAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = - Body( - addIncrementCreditLedgerEntryRequestParams = - addIncrementCreditLedgerEntryRequestParams - ) + @JvmStatic fun ofIncrement(increment: Increment) = Body(increment = increment) - @JvmStatic - fun ofAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = - Body( - addDecrementCreditLedgerEntryRequestParams = - addDecrementCreditLedgerEntryRequestParams - ) + @JvmStatic fun ofDecrement(decrement: Decrement) = Body(decrement = decrement) @JvmStatic - fun ofAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = - Body( - addExpirationChangeCreditLedgerEntryRequestParams = - addExpirationChangeCreditLedgerEntryRequestParams - ) + fun ofExpirationChange(expirationChange: ExpirationChange) = + Body(expirationChange = expirationChange) - @JvmStatic - fun ofAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = Body(addVoidCreditLedgerEntryRequestParams = addVoidCreditLedgerEntryRequestParams) + @JvmStatic fun ofVoid(void_: Void) = Body(void_ = void_) - @JvmStatic - fun ofAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = - Body( - addAmendmentCreditLedgerEntryRequestParams = - addAmendmentCreditLedgerEntryRequestParams - ) + @JvmStatic fun ofAmendment(amendment: Amendment) = Body(amendment = amendment) } /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ interface Visitor { - fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ): T + fun visitIncrement(increment: Increment): T - fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ): T + fun visitDecrement(decrement: Decrement): T - fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ): T + fun visitExpirationChange(expirationChange: ExpirationChange): T - fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ): T + fun visitVoid(void_: Void): T - fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ): T + fun visitAmendment(amendment: Amendment): T /** * Maps an unknown variant of [Body] to a value of type [T]. @@ -769,51 +561,29 @@ private constructor( when (entryType) { "increment" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body(addIncrementCreditLedgerEntryRequestParams = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(increment = it, _json = json) + } ?: Body(_json = json) } "decrement" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body(addDecrementCreditLedgerEntryRequestParams = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(decrement = it, _json = json) + } ?: Body(_json = json) } "expiration_change" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body( - addExpirationChangeCreditLedgerEntryRequestParams = it, - _json = json, - ) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(expirationChange = it, _json = json) + } ?: Body(_json = json) } "void" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(addVoidCreditLedgerEntryRequestParams = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(void_ = it, _json = json) + } ?: Body(_json = json) } "amendment" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body(addAmendmentCreditLedgerEntryRequestParams = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(amendment = it, _json = json) + } ?: Body(_json = json) } } @@ -829,28 +599,21 @@ private constructor( provider: SerializerProvider, ) { when { - value.addIncrementCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addIncrementCreditLedgerEntryRequestParams) - value.addDecrementCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addDecrementCreditLedgerEntryRequestParams) - value.addExpirationChangeCreditLedgerEntryRequestParams != null -> - generator.writeObject( - value.addExpirationChangeCreditLedgerEntryRequestParams - ) - value.addVoidCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addVoidCreditLedgerEntryRequestParams) - value.addAmendmentCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addAmendmentCreditLedgerEntryRequestParams) + value.increment != null -> generator.writeObject(value.increment) + value.decrement != null -> generator.writeObject(value.decrement) + value.expirationChange != null -> generator.writeObject(value.expirationChange) + value.void_ != null -> generator.writeObject(value.void_) + value.amendment != null -> generator.writeObject(value.amendment) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") } } } - class AddIncrementCreditLedgerEntryRequestParams + class Increment private constructor( private val amount: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val currency: JsonField, private val description: JsonField, private val effectiveDate: JsonField, @@ -866,9 +629,7 @@ private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -914,11 +675,15 @@ private constructor( fun amount(): Double = amount.getRequired("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). + * Expected to always return the following: + * ```java + * JsonValue.from("increment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -995,16 +760,6 @@ private constructor( */ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [currency]. * @@ -1088,23 +843,21 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddIncrementCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [Increment]. * * The following fields are required: * ```java * .amount() - * .entryType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddIncrementCreditLedgerEntryRequestParams]. */ + /** A builder for [Increment]. */ class Builder internal constructor() { private var amount: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("increment") private var currency: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var effectiveDate: JsonField = JsonMissing.of() @@ -1115,22 +868,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = apply { - amount = addIncrementCreditLedgerEntryRequestParams.amount - entryType = addIncrementCreditLedgerEntryRequestParams.entryType - currency = addIncrementCreditLedgerEntryRequestParams.currency - description = addIncrementCreditLedgerEntryRequestParams.description - effectiveDate = addIncrementCreditLedgerEntryRequestParams.effectiveDate - expiryDate = addIncrementCreditLedgerEntryRequestParams.expiryDate - invoiceSettings = addIncrementCreditLedgerEntryRequestParams.invoiceSettings - metadata = addIncrementCreditLedgerEntryRequestParams.metadata - perUnitCostBasis = addIncrementCreditLedgerEntryRequestParams.perUnitCostBasis - additionalProperties = - addIncrementCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() + internal fun from(increment: Increment) = apply { + amount = increment.amount + entryType = increment.entryType + currency = increment.currency + description = increment.description + effectiveDate = increment.effectiveDate + expiryDate = increment.expiryDate + invoiceSettings = increment.invoiceSettings + metadata = increment.metadata + perUnitCostBasis = increment.perUnitCostBasis + additionalProperties = increment.additionalProperties.toMutableMap() } /** @@ -1148,18 +896,19 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("increment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -1335,22 +1084,21 @@ private constructor( } /** - * Returns an immutable instance of [AddIncrementCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [Increment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .amount() - * .entryType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddIncrementCreditLedgerEntryRequestParams = - AddIncrementCreditLedgerEntryRequestParams( + fun build(): Increment = + Increment( checkRequired("amount", amount), - checkRequired("entryType", entryType), + entryType, currency, description, effectiveDate, @@ -1364,13 +1112,17 @@ private constructor( private var validated: Boolean = false - fun validate(): AddIncrementCreditLedgerEntryRequestParams = apply { + fun validate(): Increment = apply { if (validated) { return@apply } amount() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("increment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } currency() description() effectiveDate() @@ -1398,7 +1150,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("increment")) 1 else 0 } + (if (currency.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (effectiveDate.asKnown().isPresent) 1 else 0) + @@ -1407,131 +1159,6 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as @@ -1965,7 +1592,7 @@ private constructor( return true } - return /* spotless:off */ other is AddIncrementCreditLedgerEntryRequestParams && 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 /* 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 */ } /* spotless:off */ @@ -1975,13 +1602,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddIncrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + "Increment{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } - class AddDecrementCreditLedgerEntryRequestParams + class Decrement private constructor( private val amount: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val currency: JsonField, private val description: JsonField, private val metadata: JsonField, @@ -1993,9 +1620,7 @@ private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -2018,11 +1643,15 @@ private constructor( fun amount(): Double = amount.getRequired("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). + * Expected to always return the following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -2060,16 +1689,6 @@ private constructor( */ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [currency]. * @@ -2113,41 +1732,34 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddDecrementCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [Decrement]. * * The following fields are required: * ```java * .amount() - * .entryType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddDecrementCreditLedgerEntryRequestParams]. */ + /** A builder for [Decrement]. */ class Builder internal constructor() { private var amount: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("decrement") private var currency: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = apply { - amount = addDecrementCreditLedgerEntryRequestParams.amount - entryType = addDecrementCreditLedgerEntryRequestParams.entryType - currency = addDecrementCreditLedgerEntryRequestParams.currency - description = addDecrementCreditLedgerEntryRequestParams.description - metadata = addDecrementCreditLedgerEntryRequestParams.metadata - additionalProperties = - addDecrementCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() + internal fun from(decrement: Decrement) = apply { + amount = decrement.amount + entryType = decrement.entryType + currency = decrement.currency + description = decrement.description + metadata = decrement.metadata + additionalProperties = decrement.additionalProperties.toMutableMap() } /** @@ -2165,18 +1777,19 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -2261,22 +1874,21 @@ private constructor( } /** - * Returns an immutable instance of [AddDecrementCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [Decrement]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .amount() - * .entryType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddDecrementCreditLedgerEntryRequestParams = - AddDecrementCreditLedgerEntryRequestParams( + fun build(): Decrement = + Decrement( checkRequired("amount", amount), - checkRequired("entryType", entryType), + entryType, currency, description, metadata, @@ -2286,13 +1898,17 @@ private constructor( private var validated: Boolean = false - fun validate(): AddDecrementCreditLedgerEntryRequestParams = apply { + fun validate(): Decrement = apply { if (validated) { return@apply } amount() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("decrement")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } currency() description() metadata().ifPresent { it.validate() } @@ -2316,168 +1932,43 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("decrement")) 1 else 0 } + (if (currency.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun toBuilder() = Builder().from(this) companion object { - @JvmField val DECREMENT = of("decrement") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - 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) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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() + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -2562,7 +2053,7 @@ private constructor( return true } - return /* spotless:off */ other is AddDecrementCreditLedgerEntryRequestParams && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + 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 */ } /* spotless:off */ @@ -2572,12 +2063,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddDecrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + "Decrement{amount=$amount, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } - class AddExpirationChangeCreditLedgerEntryRequestParams + class ExpirationChange private constructor( - private val entryType: JsonField, + private val entryType: JsonValue, private val expiryDate: JsonField, private val targetExpiryDate: JsonField, private val amount: JsonField, @@ -2590,9 +2081,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("expiry_date") @ExcludeMissing expiryDate: JsonField = JsonMissing.of(), @@ -2627,11 +2116,15 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * An ISO 8601 format date that identifies the origination credit block to expire @@ -2698,16 +2191,6 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("metadata") - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [expiryDate]. * @@ -2785,12 +2268,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddExpirationChangeCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [ExpirationChange]. * * The following fields are required: * ```java - * .entryType() * .expiryDate() * .targetExpiryDate() * ``` @@ -2798,10 +2279,10 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AddExpirationChangeCreditLedgerEntryRequestParams]. */ + /** A builder for [ExpirationChange]. */ class Builder internal constructor() { - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("expiration_change") private var expiryDate: JsonField? = null private var targetExpiryDate: JsonField? = null private var amount: JsonField = JsonMissing.of() @@ -2812,36 +2293,31 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = apply { - entryType = addExpirationChangeCreditLedgerEntryRequestParams.entryType - expiryDate = addExpirationChangeCreditLedgerEntryRequestParams.expiryDate - targetExpiryDate = - addExpirationChangeCreditLedgerEntryRequestParams.targetExpiryDate - amount = addExpirationChangeCreditLedgerEntryRequestParams.amount - blockId = addExpirationChangeCreditLedgerEntryRequestParams.blockId - currency = addExpirationChangeCreditLedgerEntryRequestParams.currency - description = addExpirationChangeCreditLedgerEntryRequestParams.description - metadata = addExpirationChangeCreditLedgerEntryRequestParams.metadata - additionalProperties = - addExpirationChangeCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() + internal fun from(expirationChange: ExpirationChange) = apply { + entryType = expirationChange.entryType + expiryDate = expirationChange.expiryDate + targetExpiryDate = expirationChange.targetExpiryDate + amount = expirationChange.amount + blockId = expirationChange.blockId + currency = expirationChange.currency + description = expirationChange.description + metadata = expirationChange.metadata + additionalProperties = expirationChange.additionalProperties.toMutableMap() } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * An ISO 8601 format date that identifies the origination credit block to expire @@ -3009,23 +2485,21 @@ private constructor( } /** - * Returns an immutable instance of - * [AddExpirationChangeCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [ExpirationChange]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .entryType() * .expiryDate() * .targetExpiryDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddExpirationChangeCreditLedgerEntryRequestParams = - AddExpirationChangeCreditLedgerEntryRequestParams( - checkRequired("entryType", entryType), + fun build(): ExpirationChange = + ExpirationChange( + entryType, checkRequired("expiryDate", expiryDate), checkRequired("targetExpiryDate", targetExpiryDate), amount, @@ -3039,12 +2513,16 @@ private constructor( private var validated: Boolean = false - fun validate(): AddExpirationChangeCreditLedgerEntryRequestParams = apply { + fun validate(): ExpirationChange = apply { if (validated) { return@apply } - entryType().validate() + _entryType().let { + if (it != JsonValue.from("expiration_change")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } expiryDate() targetExpiryDate() amount() @@ -3071,7 +2549,7 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("expiration_change")) 1 else 0 } + (if (expiryDate.asKnown().isPresent) 1 else 0) + (if (targetExpiryDate.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + @@ -3080,131 +2558,6 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -3321,7 +2674,7 @@ private constructor( return true } - return /* spotless:off */ other is AddExpirationChangeCreditLedgerEntryRequestParams && entryType == other.entryType && expiryDate == other.expiryDate && targetExpiryDate == other.targetExpiryDate && amount == other.amount && blockId == other.blockId && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExpirationChange && entryType == other.entryType && expiryDate == other.expiryDate && targetExpiryDate == other.targetExpiryDate && amount == other.amount && blockId == other.blockId && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3331,14 +2684,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddExpirationChangeCreditLedgerEntryRequestParams{entryType=$entryType, expiryDate=$expiryDate, targetExpiryDate=$targetExpiryDate, amount=$amount, blockId=$blockId, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + "ExpirationChange{entryType=$entryType, expiryDate=$expiryDate, targetExpiryDate=$targetExpiryDate, amount=$amount, blockId=$blockId, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } - class AddVoidCreditLedgerEntryRequestParams + class Void private constructor( private val amount: JsonField, private val blockId: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val currency: JsonField, private val description: JsonField, private val metadata: JsonField, @@ -3354,9 +2707,7 @@ private constructor( @JsonProperty("block_id") @ExcludeMissing blockId: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -3400,11 +2751,15 @@ private constructor( fun blockId(): String = blockId.getRequired("block_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). + * Expected to always return the following: + * ```java + * JsonValue.from("void") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -3457,16 +2812,6 @@ private constructor( */ @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [currency]. * @@ -3520,25 +2865,23 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddVoidCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [Void]. * * The following fields are required: * ```java * .amount() * .blockId() - * .entryType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddVoidCreditLedgerEntryRequestParams]. */ + /** A builder for [Void]. */ class Builder internal constructor() { private var amount: JsonField? = null private var blockId: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void") private var currency: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() @@ -3546,18 +2889,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = apply { - amount = addVoidCreditLedgerEntryRequestParams.amount - blockId = addVoidCreditLedgerEntryRequestParams.blockId - entryType = addVoidCreditLedgerEntryRequestParams.entryType - currency = addVoidCreditLedgerEntryRequestParams.currency - description = addVoidCreditLedgerEntryRequestParams.description - metadata = addVoidCreditLedgerEntryRequestParams.metadata - voidReason = addVoidCreditLedgerEntryRequestParams.voidReason - additionalProperties = - addVoidCreditLedgerEntryRequestParams.additionalProperties.toMutableMap() + internal fun from(void_: Void) = apply { + amount = void_.amount + blockId = void_.blockId + entryType = void_.entryType + currency = void_.currency + description = void_.description + metadata = void_.metadata + voidReason = void_.voidReason + additionalProperties = void_.additionalProperties.toMutableMap() } /** @@ -3587,18 +2927,19 @@ private constructor( */ fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -3702,7 +3043,7 @@ private constructor( } /** - * Returns an immutable instance of [AddVoidCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [Void]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3710,16 +3051,15 @@ private constructor( * ```java * .amount() * .blockId() - * .entryType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddVoidCreditLedgerEntryRequestParams = - AddVoidCreditLedgerEntryRequestParams( + fun build(): Void = + Void( checkRequired("amount", amount), checkRequired("blockId", blockId), - checkRequired("entryType", entryType), + entryType, currency, description, metadata, @@ -3730,14 +3070,18 @@ private constructor( private var validated: Boolean = false - fun validate(): AddVoidCreditLedgerEntryRequestParams = apply { + fun validate(): Void = apply { if (validated) { return@apply } amount() blockId() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } currency() description() metadata().ifPresent { it.validate() } @@ -3763,137 +3107,12 @@ private constructor( internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + (if (blockId.asKnown().isPresent) 1 else 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void")) 1 else 0 } + (if (currency.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (voidReason.asKnown().getOrNull()?.validity() ?: 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -4137,7 +3356,7 @@ private constructor( return true } - return /* spotless:off */ other is AddVoidCreditLedgerEntryRequestParams && 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 /* 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 */ } /* spotless:off */ @@ -4147,14 +3366,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddVoidCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "Void{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class AddAmendmentCreditLedgerEntryRequestParams + class Amendment private constructor( private val amount: JsonField, private val blockId: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val currency: JsonField, private val description: JsonField, private val metadata: JsonField, @@ -4169,9 +3388,7 @@ private constructor( @JsonProperty("block_id") @ExcludeMissing blockId: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -4203,11 +3420,15 @@ private constructor( fun blockId(): String = blockId.getRequired("block_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). + * Expected to always return the following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -4252,16 +3473,6 @@ private constructor( */ @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [currency]. * @@ -4305,44 +3516,37 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddAmendmentCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [Amendment]. * * The following fields are required: * ```java * .amount() * .blockId() - * .entryType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddAmendmentCreditLedgerEntryRequestParams]. */ + /** A builder for [Amendment]. */ class Builder internal constructor() { private var amount: JsonField? = null private var blockId: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("amendment") private var currency: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = apply { - amount = addAmendmentCreditLedgerEntryRequestParams.amount - blockId = addAmendmentCreditLedgerEntryRequestParams.blockId - entryType = addAmendmentCreditLedgerEntryRequestParams.entryType - currency = addAmendmentCreditLedgerEntryRequestParams.currency - description = addAmendmentCreditLedgerEntryRequestParams.description - metadata = addAmendmentCreditLedgerEntryRequestParams.metadata - additionalProperties = - addAmendmentCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() + internal fun from(amendment: Amendment) = apply { + amount = amendment.amount + blockId = amendment.blockId + entryType = amendment.entryType + currency = amendment.currency + description = amendment.description + metadata = amendment.metadata + additionalProperties = amendment.additionalProperties.toMutableMap() } /** @@ -4372,18 +3576,19 @@ private constructor( */ fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -4468,7 +3673,7 @@ private constructor( } /** - * Returns an immutable instance of [AddAmendmentCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [Amendment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4476,16 +3681,15 @@ private constructor( * ```java * .amount() * .blockId() - * .entryType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddAmendmentCreditLedgerEntryRequestParams = - AddAmendmentCreditLedgerEntryRequestParams( + fun build(): Amendment = + Amendment( checkRequired("amount", amount), checkRequired("blockId", blockId), - checkRequired("entryType", entryType), + entryType, currency, description, metadata, @@ -4495,14 +3699,18 @@ private constructor( private var validated: Boolean = false - fun validate(): AddAmendmentCreditLedgerEntryRequestParams = apply { + fun validate(): Amendment = apply { if (validated) { return@apply } amount() blockId() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("amendment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } currency() description() metadata().ifPresent { it.validate() } @@ -4527,136 +3735,11 @@ private constructor( internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + (if (blockId.asKnown().isPresent) 1 else 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("amendment")) 1 else 0 } + (if (currency.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -4773,7 +3856,7 @@ private constructor( return true } - return /* spotless:off */ other is AddAmendmentCreditLedgerEntryRequestParams && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + 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 */ } /* spotless:off */ @@ -4783,7 +3866,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddAmendmentCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + "Amendment{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } } 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 0f1b25f8..d555e9b9 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 @@ -38,84 +38,69 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = CustomerCreditLedgerCreateEntryByExternalIdResponse.Serializer::class) class CustomerCreditLedgerCreateEntryByExternalIdResponse private constructor( - private val incrementLedgerEntry: IncrementLedgerEntry? = null, - private val decrementLedgerEntry: DecrementLedgerEntry? = null, - private val expirationChangeLedgerEntry: ExpirationChangeLedgerEntry? = null, - private val creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry? = null, - private val voidLedgerEntry: VoidLedgerEntry? = null, - private val voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry? = null, - private val amendmentLedgerEntry: AmendmentLedgerEntry? = null, + private val increment: Increment? = null, + private val decrement: Decrement? = null, + private val expirationChange: ExpirationChange? = null, + private val creditBlockExpiry: CreditBlockExpiry? = null, + private val void_: Void? = null, + private val voidInitiated: VoidInitiated? = null, + private val amendment: Amendment? = null, private val _json: JsonValue? = null, ) { - fun incrementLedgerEntry(): Optional = - Optional.ofNullable(incrementLedgerEntry) + fun increment(): Optional = Optional.ofNullable(increment) - fun decrementLedgerEntry(): Optional = - Optional.ofNullable(decrementLedgerEntry) + fun decrement(): Optional = Optional.ofNullable(decrement) - fun expirationChangeLedgerEntry(): Optional = - Optional.ofNullable(expirationChangeLedgerEntry) + fun expirationChange(): Optional = Optional.ofNullable(expirationChange) - fun creditBlockExpiryLedgerEntry(): Optional = - Optional.ofNullable(creditBlockExpiryLedgerEntry) + fun creditBlockExpiry(): Optional = Optional.ofNullable(creditBlockExpiry) - fun voidLedgerEntry(): Optional = Optional.ofNullable(voidLedgerEntry) + fun void_(): Optional = Optional.ofNullable(void_) - fun voidInitiatedLedgerEntry(): Optional = - Optional.ofNullable(voidInitiatedLedgerEntry) + fun voidInitiated(): Optional = Optional.ofNullable(voidInitiated) - fun amendmentLedgerEntry(): Optional = - Optional.ofNullable(amendmentLedgerEntry) + fun amendment(): Optional = Optional.ofNullable(amendment) - fun isIncrementLedgerEntry(): Boolean = incrementLedgerEntry != null + fun isIncrement(): Boolean = increment != null - fun isDecrementLedgerEntry(): Boolean = decrementLedgerEntry != null + fun isDecrement(): Boolean = decrement != null - fun isExpirationChangeLedgerEntry(): Boolean = expirationChangeLedgerEntry != null + fun isExpirationChange(): Boolean = expirationChange != null - fun isCreditBlockExpiryLedgerEntry(): Boolean = creditBlockExpiryLedgerEntry != null + fun isCreditBlockExpiry(): Boolean = creditBlockExpiry != null - fun isVoidLedgerEntry(): Boolean = voidLedgerEntry != null + fun isVoid(): Boolean = void_ != null - fun isVoidInitiatedLedgerEntry(): Boolean = voidInitiatedLedgerEntry != null + fun isVoidInitiated(): Boolean = voidInitiated != null - fun isAmendmentLedgerEntry(): Boolean = amendmentLedgerEntry != null + fun isAmendment(): Boolean = amendment != null - fun asIncrementLedgerEntry(): IncrementLedgerEntry = - incrementLedgerEntry.getOrThrow("incrementLedgerEntry") + fun asIncrement(): Increment = increment.getOrThrow("increment") - fun asDecrementLedgerEntry(): DecrementLedgerEntry = - decrementLedgerEntry.getOrThrow("decrementLedgerEntry") + fun asDecrement(): Decrement = decrement.getOrThrow("decrement") - fun asExpirationChangeLedgerEntry(): ExpirationChangeLedgerEntry = - expirationChangeLedgerEntry.getOrThrow("expirationChangeLedgerEntry") + fun asExpirationChange(): ExpirationChange = expirationChange.getOrThrow("expirationChange") - fun asCreditBlockExpiryLedgerEntry(): CreditBlockExpiryLedgerEntry = - creditBlockExpiryLedgerEntry.getOrThrow("creditBlockExpiryLedgerEntry") + fun asCreditBlockExpiry(): CreditBlockExpiry = creditBlockExpiry.getOrThrow("creditBlockExpiry") - fun asVoidLedgerEntry(): VoidLedgerEntry = voidLedgerEntry.getOrThrow("voidLedgerEntry") + fun asVoid(): Void = void_.getOrThrow("void_") - fun asVoidInitiatedLedgerEntry(): VoidInitiatedLedgerEntry = - voidInitiatedLedgerEntry.getOrThrow("voidInitiatedLedgerEntry") + fun asVoidInitiated(): VoidInitiated = voidInitiated.getOrThrow("voidInitiated") - fun asAmendmentLedgerEntry(): AmendmentLedgerEntry = - amendmentLedgerEntry.getOrThrow("amendmentLedgerEntry") + fun asAmendment(): Amendment = amendment.getOrThrow("amendment") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) - decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) - expirationChangeLedgerEntry != null -> - visitor.visitExpirationChangeLedgerEntry(expirationChangeLedgerEntry) - creditBlockExpiryLedgerEntry != null -> - visitor.visitCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry) - voidLedgerEntry != null -> visitor.visitVoidLedgerEntry(voidLedgerEntry) - voidInitiatedLedgerEntry != null -> - visitor.visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry) - amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) + increment != null -> visitor.visitIncrement(increment) + decrement != null -> visitor.visitDecrement(decrement) + expirationChange != null -> visitor.visitExpirationChange(expirationChange) + creditBlockExpiry != null -> visitor.visitCreditBlockExpiry(creditBlockExpiry) + void_ != null -> visitor.visitVoid(void_) + voidInitiated != null -> visitor.visitVoidInitiated(voidInitiated) + amendment != null -> visitor.visitAmendment(amendment) else -> visitor.unknown(_json) } @@ -128,38 +113,32 @@ private constructor( accept( object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) { - incrementLedgerEntry.validate() + override fun visitIncrement(increment: Increment) { + increment.validate() } - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) { - decrementLedgerEntry.validate() + override fun visitDecrement(decrement: Decrement) { + decrement.validate() } - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) { - expirationChangeLedgerEntry.validate() + override fun visitExpirationChange(expirationChange: ExpirationChange) { + expirationChange.validate() } - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) { - creditBlockExpiryLedgerEntry.validate() + override fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) { + creditBlockExpiry.validate() } - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) { - voidLedgerEntry.validate() + override fun visitVoid(void_: Void) { + void_.validate() } - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) { - voidInitiatedLedgerEntry.validate() + override fun visitVoidInitiated(voidInitiated: VoidInitiated) { + voidInitiated.validate() } - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) { - amendmentLedgerEntry.validate() + override fun visitAmendment(amendment: Amendment) { + amendment.validate() } } ) @@ -183,29 +162,22 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - incrementLedgerEntry.validity() + override fun visitIncrement(increment: Increment) = increment.validity() - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - decrementLedgerEntry.validity() + override fun visitDecrement(decrement: Decrement) = decrement.validity() - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = expirationChangeLedgerEntry.validity() + override fun visitExpirationChange(expirationChange: ExpirationChange) = + expirationChange.validity() - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = creditBlockExpiryLedgerEntry.validity() + override fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) = + creditBlockExpiry.validity() - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - voidLedgerEntry.validity() + override fun visitVoid(void_: Void) = void_.validity() - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) = voidInitiatedLedgerEntry.validity() + override fun visitVoidInitiated(voidInitiated: VoidInitiated) = + voidInitiated.validity() - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - amendmentLedgerEntry.validity() + override fun visitAmendment(amendment: Amendment) = amendment.validity() override fun unknown(json: JsonValue?) = 0 } @@ -216,27 +188,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryByExternalIdResponse && incrementLedgerEntry == other.incrementLedgerEntry && decrementLedgerEntry == other.decrementLedgerEntry && expirationChangeLedgerEntry == other.expirationChangeLedgerEntry && creditBlockExpiryLedgerEntry == other.creditBlockExpiryLedgerEntry && voidLedgerEntry == other.voidLedgerEntry && voidInitiatedLedgerEntry == other.voidInitiatedLedgerEntry && amendmentLedgerEntry == other.amendmentLedgerEntry /* spotless:on */ + 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 */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementLedgerEntry, decrementLedgerEntry, expirationChangeLedgerEntry, creditBlockExpiryLedgerEntry, voidLedgerEntry, voidInitiatedLedgerEntry, amendmentLedgerEntry) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, creditBlockExpiry, void_, voidInitiated, amendment) /* spotless:on */ override fun toString(): String = when { - incrementLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{incrementLedgerEntry=$incrementLedgerEntry}" - decrementLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{decrementLedgerEntry=$decrementLedgerEntry}" - expirationChangeLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{expirationChangeLedgerEntry=$expirationChangeLedgerEntry}" - creditBlockExpiryLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{creditBlockExpiryLedgerEntry=$creditBlockExpiryLedgerEntry}" - voidLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{voidLedgerEntry=$voidLedgerEntry}" - voidInitiatedLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{voidInitiatedLedgerEntry=$voidInitiatedLedgerEntry}" - amendmentLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryByExternalIdResponse{amendmentLedgerEntry=$amendmentLedgerEntry}" + increment != null -> + "CustomerCreditLedgerCreateEntryByExternalIdResponse{increment=$increment}" + decrement != null -> + "CustomerCreditLedgerCreateEntryByExternalIdResponse{decrement=$decrement}" + expirationChange != null -> + "CustomerCreditLedgerCreateEntryByExternalIdResponse{expirationChange=$expirationChange}" + creditBlockExpiry != null -> + "CustomerCreditLedgerCreateEntryByExternalIdResponse{creditBlockExpiry=$creditBlockExpiry}" + void_ != null -> "CustomerCreditLedgerCreateEntryByExternalIdResponse{void_=$void_}" + voidInitiated != null -> + "CustomerCreditLedgerCreateEntryByExternalIdResponse{voidInitiated=$voidInitiated}" + amendment != null -> + "CustomerCreditLedgerCreateEntryByExternalIdResponse{amendment=$amendment}" _json != null -> "CustomerCreditLedgerCreateEntryByExternalIdResponse{_unknown=$_json}" else -> throw IllegalStateException( @@ -247,48 +218,33 @@ private constructor( companion object { @JvmStatic - fun ofIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - incrementLedgerEntry = incrementLedgerEntry - ) + fun ofIncrement(increment: Increment) = + CustomerCreditLedgerCreateEntryByExternalIdResponse(increment = increment) @JvmStatic - fun ofDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - decrementLedgerEntry = decrementLedgerEntry - ) + fun ofDecrement(decrement: Decrement) = + CustomerCreditLedgerCreateEntryByExternalIdResponse(decrement = decrement) @JvmStatic - fun ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - expirationChangeLedgerEntry = expirationChangeLedgerEntry - ) + fun ofExpirationChange(expirationChange: ExpirationChange) = + CustomerCreditLedgerCreateEntryByExternalIdResponse(expirationChange = expirationChange) @JvmStatic - fun ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = + fun ofCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) = CustomerCreditLedgerCreateEntryByExternalIdResponse( - creditBlockExpiryLedgerEntry = creditBlockExpiryLedgerEntry + creditBlockExpiry = creditBlockExpiry ) @JvmStatic - fun ofVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse(voidLedgerEntry = voidLedgerEntry) + fun ofVoid(void_: Void) = CustomerCreditLedgerCreateEntryByExternalIdResponse(void_ = void_) @JvmStatic - fun ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidInitiatedLedgerEntry = voidInitiatedLedgerEntry - ) + fun ofVoidInitiated(voidInitiated: VoidInitiated) = + CustomerCreditLedgerCreateEntryByExternalIdResponse(voidInitiated = voidInitiated) @JvmStatic - fun ofAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - CustomerCreditLedgerCreateEntryByExternalIdResponse( - amendmentLedgerEntry = amendmentLedgerEntry - ) + fun ofAmendment(amendment: Amendment) = + CustomerCreditLedgerCreateEntryByExternalIdResponse(amendment = amendment) } /** @@ -297,23 +253,19 @@ private constructor( */ interface Visitor { - fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry): T + fun visitIncrement(increment: Increment): T - fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry): T + fun visitDecrement(decrement: Decrement): T - fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ): T + fun visitExpirationChange(expirationChange: ExpirationChange): T - fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ): T + fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry): T - fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry): T + fun visitVoid(void_: Void): T - fun visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry): T + fun visitVoidInitiated(voidInitiated: VoidInitiated): T - fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry): T + fun visitAmendment(amendment: Amendment): T /** * Maps an unknown variant of [CustomerCreditLedgerCreateEntryByExternalIdResponse] to a @@ -346,59 +298,57 @@ private constructor( when (entryType) { "increment" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { CustomerCreditLedgerCreateEntryByExternalIdResponse( - incrementLedgerEntry = it, + increment = it, _json = json, ) } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "decrement" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { CustomerCreditLedgerCreateEntryByExternalIdResponse( - decrementLedgerEntry = it, + decrement = it, _json = json, ) } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "expiration_change" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - CustomerCreditLedgerCreateEntryByExternalIdResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryByExternalIdResponse( + expirationChange = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "credit_block_expiry" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - CustomerCreditLedgerCreateEntryByExternalIdResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryByExternalIdResponse( + creditBlockExpiry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "void" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidLedgerEntry = it, + void_ = it, _json = json, ) } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "void_initiated" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { CustomerCreditLedgerCreateEntryByExternalIdResponse( - voidInitiatedLedgerEntry = it, + voidInitiated = it, _json = json, ) } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) } "amendment" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { CustomerCreditLedgerCreateEntryByExternalIdResponse( - amendmentLedgerEntry = it, + amendment = it, _json = json, ) } ?: CustomerCreditLedgerCreateEntryByExternalIdResponse(_json = json) @@ -420,19 +370,13 @@ private constructor( provider: SerializerProvider, ) { when { - value.incrementLedgerEntry != null -> - generator.writeObject(value.incrementLedgerEntry) - value.decrementLedgerEntry != null -> - generator.writeObject(value.decrementLedgerEntry) - value.expirationChangeLedgerEntry != null -> - generator.writeObject(value.expirationChangeLedgerEntry) - value.creditBlockExpiryLedgerEntry != null -> - generator.writeObject(value.creditBlockExpiryLedgerEntry) - value.voidLedgerEntry != null -> generator.writeObject(value.voidLedgerEntry) - value.voidInitiatedLedgerEntry != null -> - generator.writeObject(value.voidInitiatedLedgerEntry) - value.amendmentLedgerEntry != null -> - generator.writeObject(value.amendmentLedgerEntry) + value.increment != null -> generator.writeObject(value.increment) + value.decrement != null -> generator.writeObject(value.decrement) + value.expirationChange != null -> generator.writeObject(value.expirationChange) + value.creditBlockExpiry != null -> generator.writeObject(value.creditBlockExpiry) + value.void_ != null -> generator.writeObject(value.void_) + value.voidInitiated != null -> generator.writeObject(value.voidInitiated) + value.amendment != null -> generator.writeObject(value.amendment) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( @@ -442,7 +386,7 @@ private constructor( } } - class IncrementLedgerEntry + class Increment private constructor( private val id: JsonField, private val amount: JsonField, @@ -453,7 +397,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -485,9 +429,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -569,10 +511,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("increment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -671,15 +618,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -722,7 +660,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [IncrementLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Increment]. * * The following fields are required: * ```java @@ -735,7 +673,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -744,7 +681,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [IncrementLedgerEntry]. */ + /** A builder for [Increment]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -756,28 +693,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("increment") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(incrementLedgerEntry: IncrementLedgerEntry) = apply { - id = incrementLedgerEntry.id - amount = incrementLedgerEntry.amount - createdAt = incrementLedgerEntry.createdAt - creditBlock = incrementLedgerEntry.creditBlock - currency = incrementLedgerEntry.currency - customer = incrementLedgerEntry.customer - description = incrementLedgerEntry.description - endingBalance = incrementLedgerEntry.endingBalance - entryStatus = incrementLedgerEntry.entryStatus - entryType = incrementLedgerEntry.entryType - ledgerSequenceNumber = incrementLedgerEntry.ledgerSequenceNumber - metadata = incrementLedgerEntry.metadata - startingBalance = incrementLedgerEntry.startingBalance - additionalProperties = incrementLedgerEntry.additionalProperties.toMutableMap() + internal fun from(increment: Increment) = apply { + id = increment.id + amount = increment.amount + createdAt = increment.createdAt + creditBlock = increment.creditBlock + currency = increment.currency + customer = increment.customer + description = increment.description + endingBalance = increment.endingBalance + entryStatus = increment.entryStatus + entryType = increment.entryType + ledgerSequenceNumber = increment.ledgerSequenceNumber + metadata = increment.metadata + startingBalance = increment.startingBalance + additionalProperties = increment.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -892,16 +829,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("increment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -967,7 +907,7 @@ private constructor( } /** - * Returns an immutable instance of [IncrementLedgerEntry]. + * Returns an immutable instance of [Increment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -982,7 +922,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -990,8 +929,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): IncrementLedgerEntry = - IncrementLedgerEntry( + fun build(): Increment = + Increment( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -1001,7 +940,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -1011,7 +950,7 @@ private constructor( private var validated: Boolean = false - fun validate(): IncrementLedgerEntry = apply { + fun validate(): Increment = apply { if (validated) { return@apply } @@ -1025,7 +964,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("increment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -1057,7 +1000,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("increment")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -1656,129 +1599,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -1893,7 +1713,7 @@ 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 && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Increment && 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 */ } /* spotless:off */ @@ -1903,10 +1723,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "IncrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "Increment{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class DecrementLedgerEntry + class Decrement private constructor( private val id: JsonField, private val amount: JsonField, @@ -1917,7 +1737,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -1952,9 +1772,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -2044,10 +1862,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -2164,15 +1987,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -2236,7 +2050,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DecrementLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Decrement]. * * The following fields are required: * ```java @@ -2249,7 +2063,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -2258,7 +2071,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DecrementLedgerEntry]. */ + /** A builder for [Decrement]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -2270,7 +2083,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("decrement") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null @@ -2280,24 +2093,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(decrementLedgerEntry: DecrementLedgerEntry) = apply { - id = decrementLedgerEntry.id - amount = decrementLedgerEntry.amount - createdAt = decrementLedgerEntry.createdAt - creditBlock = decrementLedgerEntry.creditBlock - currency = decrementLedgerEntry.currency - customer = decrementLedgerEntry.customer - description = decrementLedgerEntry.description - endingBalance = decrementLedgerEntry.endingBalance - entryStatus = decrementLedgerEntry.entryStatus - entryType = decrementLedgerEntry.entryType - ledgerSequenceNumber = decrementLedgerEntry.ledgerSequenceNumber - metadata = decrementLedgerEntry.metadata - startingBalance = decrementLedgerEntry.startingBalance - eventId = decrementLedgerEntry.eventId - invoiceId = decrementLedgerEntry.invoiceId - priceId = decrementLedgerEntry.priceId - additionalProperties = decrementLedgerEntry.additionalProperties.toMutableMap() + internal fun from(decrement: Decrement) = apply { + id = decrement.id + amount = decrement.amount + createdAt = decrement.createdAt + creditBlock = decrement.creditBlock + currency = decrement.currency + customer = decrement.customer + description = decrement.description + endingBalance = decrement.endingBalance + entryStatus = decrement.entryStatus + entryType = decrement.entryType + ledgerSequenceNumber = decrement.ledgerSequenceNumber + metadata = decrement.metadata + startingBalance = decrement.startingBalance + eventId = decrement.eventId + invoiceId = decrement.invoiceId + priceId = decrement.priceId + additionalProperties = decrement.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2412,16 +2225,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -2529,7 +2345,7 @@ private constructor( } /** - * Returns an immutable instance of [DecrementLedgerEntry]. + * Returns an immutable instance of [Decrement]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2544,7 +2360,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -2552,8 +2367,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DecrementLedgerEntry = - DecrementLedgerEntry( + fun build(): Decrement = + Decrement( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -2563,7 +2378,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -2576,7 +2391,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DecrementLedgerEntry = apply { + fun validate(): Decrement = apply { if (validated) { return@apply } @@ -2590,7 +2405,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("decrement")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -2625,7 +2444,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("decrement")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) + @@ -3227,170 +3046,47 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * 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 + ) { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - companion object { + fun toBuilder() = Builder().from(this) - @JvmField val DECREMENT = of("decrement") + companion object { - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DECREMENT -> Value.DECREMENT - else -> Value._UNKNOWN + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @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 putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -3464,7 +3160,7 @@ 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 /* spotless:off */ other is Decrement && 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 */ } /* spotless:off */ @@ -3474,10 +3170,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DecrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" + "Decrement{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" } - class ExpirationChangeLedgerEntry + class ExpirationChange private constructor( private val id: JsonField, private val amount: JsonField, @@ -3488,7 +3184,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val newBlockExpiryDate: JsonField, @@ -3521,9 +3217,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -3609,10 +3303,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -3718,15 +3417,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -3779,8 +3469,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExpirationChangeLedgerEntry]. + * Returns a mutable builder for constructing an instance of [ExpirationChange]. * * The following fields are required: * ```java @@ -3793,7 +3482,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -3803,7 +3491,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExpirationChangeLedgerEntry]. */ + /** A builder for [ExpirationChange]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -3815,7 +3503,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("expiration_change") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var newBlockExpiryDate: JsonField? = null @@ -3823,23 +3511,22 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(expirationChangeLedgerEntry: ExpirationChangeLedgerEntry) = apply { - id = expirationChangeLedgerEntry.id - amount = expirationChangeLedgerEntry.amount - createdAt = expirationChangeLedgerEntry.createdAt - creditBlock = expirationChangeLedgerEntry.creditBlock - currency = expirationChangeLedgerEntry.currency - customer = expirationChangeLedgerEntry.customer - description = expirationChangeLedgerEntry.description - endingBalance = expirationChangeLedgerEntry.endingBalance - entryStatus = expirationChangeLedgerEntry.entryStatus - entryType = expirationChangeLedgerEntry.entryType - ledgerSequenceNumber = expirationChangeLedgerEntry.ledgerSequenceNumber - metadata = expirationChangeLedgerEntry.metadata - newBlockExpiryDate = expirationChangeLedgerEntry.newBlockExpiryDate - startingBalance = expirationChangeLedgerEntry.startingBalance - additionalProperties = - expirationChangeLedgerEntry.additionalProperties.toMutableMap() + internal fun from(expirationChange: ExpirationChange) = apply { + id = expirationChange.id + amount = expirationChange.amount + createdAt = expirationChange.createdAt + creditBlock = expirationChange.creditBlock + currency = expirationChange.currency + customer = expirationChange.customer + description = expirationChange.description + endingBalance = expirationChange.endingBalance + entryStatus = expirationChange.entryStatus + entryType = expirationChange.entryType + ledgerSequenceNumber = expirationChange.ledgerSequenceNumber + metadata = expirationChange.metadata + newBlockExpiryDate = expirationChange.newBlockExpiryDate + startingBalance = expirationChange.startingBalance + additionalProperties = expirationChange.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3954,16 +3641,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -4050,7 +3740,7 @@ private constructor( } /** - * Returns an immutable instance of [ExpirationChangeLedgerEntry]. + * Returns an immutable instance of [ExpirationChange]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4065,7 +3755,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -4074,8 +3763,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): ExpirationChangeLedgerEntry = - ExpirationChangeLedgerEntry( + fun build(): ExpirationChange = + ExpirationChange( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -4085,7 +3774,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("newBlockExpiryDate", newBlockExpiryDate), @@ -4096,7 +3785,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExpirationChangeLedgerEntry = apply { + fun validate(): ExpirationChange = apply { if (validated) { return@apply } @@ -4110,7 +3799,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("expiration_change")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -4143,7 +3836,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("expiration_change")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + @@ -4743,129 +4436,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -4980,7 +4550,7 @@ 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 /* spotless:off */ other is ExpirationChange && 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 */ } /* spotless:off */ @@ -4990,10 +4560,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExpirationChangeLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "ExpirationChange{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class CreditBlockExpiryLedgerEntry + class CreditBlockExpiry private constructor( private val id: JsonField, private val amount: JsonField, @@ -5004,7 +4574,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -5036,9 +4606,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -5120,10 +4688,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("credit_block_expiry") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -5222,15 +4795,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -5273,8 +4837,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CreditBlockExpiryLedgerEntry]. + * Returns a mutable builder for constructing an instance of [CreditBlockExpiry]. * * The following fields are required: * ```java @@ -5287,7 +4850,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -5296,7 +4858,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CreditBlockExpiryLedgerEntry]. */ + /** A builder for [CreditBlockExpiry]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -5308,29 +4870,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("credit_block_expiry") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry) = apply { - id = creditBlockExpiryLedgerEntry.id - amount = creditBlockExpiryLedgerEntry.amount - createdAt = creditBlockExpiryLedgerEntry.createdAt - creditBlock = creditBlockExpiryLedgerEntry.creditBlock - currency = creditBlockExpiryLedgerEntry.currency - customer = creditBlockExpiryLedgerEntry.customer - description = creditBlockExpiryLedgerEntry.description - endingBalance = creditBlockExpiryLedgerEntry.endingBalance - entryStatus = creditBlockExpiryLedgerEntry.entryStatus - entryType = creditBlockExpiryLedgerEntry.entryType - ledgerSequenceNumber = creditBlockExpiryLedgerEntry.ledgerSequenceNumber - metadata = creditBlockExpiryLedgerEntry.metadata - startingBalance = creditBlockExpiryLedgerEntry.startingBalance - additionalProperties = - creditBlockExpiryLedgerEntry.additionalProperties.toMutableMap() + internal fun from(creditBlockExpiry: CreditBlockExpiry) = apply { + id = creditBlockExpiry.id + amount = creditBlockExpiry.amount + createdAt = creditBlockExpiry.createdAt + creditBlock = creditBlockExpiry.creditBlock + currency = creditBlockExpiry.currency + customer = creditBlockExpiry.customer + description = creditBlockExpiry.description + endingBalance = creditBlockExpiry.endingBalance + entryStatus = creditBlockExpiry.entryStatus + entryType = creditBlockExpiry.entryType + ledgerSequenceNumber = creditBlockExpiry.ledgerSequenceNumber + metadata = creditBlockExpiry.metadata + startingBalance = creditBlockExpiry.startingBalance + additionalProperties = creditBlockExpiry.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -5445,16 +5006,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("credit_block_expiry") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -5520,7 +5084,7 @@ private constructor( } /** - * Returns an immutable instance of [CreditBlockExpiryLedgerEntry]. + * Returns an immutable instance of [CreditBlockExpiry]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -5535,7 +5099,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -5543,8 +5106,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CreditBlockExpiryLedgerEntry = - CreditBlockExpiryLedgerEntry( + fun build(): CreditBlockExpiry = + CreditBlockExpiry( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -5554,7 +5117,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -5564,7 +5127,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CreditBlockExpiryLedgerEntry = apply { + fun validate(): CreditBlockExpiry = apply { if (validated) { return@apply } @@ -5578,7 +5141,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("credit_block_expiry")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -5610,7 +5177,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("credit_block_expiry")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -6209,129 +5776,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 CREDIT_BLOCK_EXPIRY = of("credit_block_expiry") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - CREDIT_BLOCK_EXPIRY - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREDIT_BLOCK_EXPIRY, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CREDIT_BLOCK_EXPIRY -> Value.CREDIT_BLOCK_EXPIRY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREDIT_BLOCK_EXPIRY -> Known.CREDIT_BLOCK_EXPIRY - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -6446,7 +5890,7 @@ 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 /* spotless:off */ other is CreditBlockExpiry && 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 */ } /* spotless:off */ @@ -6456,10 +5900,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CreditBlockExpiryLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "CreditBlockExpiry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class VoidLedgerEntry + class Void private constructor( private val id: JsonField, private val amount: JsonField, @@ -6470,7 +5914,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -6504,9 +5948,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -6596,10 +6038,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("void") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -6710,15 +6157,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -6779,7 +6217,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [VoidLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Void]. * * The following fields are required: * ```java @@ -6792,7 +6230,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -6803,7 +6240,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VoidLedgerEntry]. */ + /** A builder for [Void]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -6815,7 +6252,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null @@ -6824,23 +6261,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(voidLedgerEntry: VoidLedgerEntry) = apply { - id = voidLedgerEntry.id - amount = voidLedgerEntry.amount - createdAt = voidLedgerEntry.createdAt - creditBlock = voidLedgerEntry.creditBlock - currency = voidLedgerEntry.currency - customer = voidLedgerEntry.customer - description = voidLedgerEntry.description - endingBalance = voidLedgerEntry.endingBalance - entryStatus = voidLedgerEntry.entryStatus - entryType = voidLedgerEntry.entryType - ledgerSequenceNumber = voidLedgerEntry.ledgerSequenceNumber - metadata = voidLedgerEntry.metadata - startingBalance = voidLedgerEntry.startingBalance - voidAmount = voidLedgerEntry.voidAmount - voidReason = voidLedgerEntry.voidReason - additionalProperties = voidLedgerEntry.additionalProperties.toMutableMap() + internal fun from(void_: Void) = apply { + id = void_.id + amount = void_.amount + createdAt = void_.createdAt + creditBlock = void_.creditBlock + currency = void_.currency + customer = void_.customer + description = void_.description + endingBalance = void_.endingBalance + entryStatus = void_.entryStatus + entryType = void_.entryType + ledgerSequenceNumber = void_.ledgerSequenceNumber + metadata = void_.metadata + startingBalance = void_.startingBalance + voidAmount = void_.voidAmount + voidReason = void_.voidReason + additionalProperties = void_.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -6955,16 +6392,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -7055,7 +6495,7 @@ private constructor( } /** - * Returns an immutable instance of [VoidLedgerEntry]. + * Returns an immutable instance of [Void]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7070,7 +6510,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -7080,8 +6519,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VoidLedgerEntry = - VoidLedgerEntry( + fun build(): Void = + Void( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -7091,7 +6530,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -7103,7 +6542,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VoidLedgerEntry = apply { + fun validate(): Void = apply { if (validated) { return@apply } @@ -7117,7 +6556,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -7151,7 +6594,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) + @@ -7696,131 +7139,8 @@ private constructor( fun known(): Known = when (this) { COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryStatus = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") + PENDING -> Known.PENDING + else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") } /** @@ -7837,7 +7157,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EntryType = apply { + fun validate(): EntryStatus = apply { if (validated) { return@apply } @@ -7867,7 +7187,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -7989,7 +7309,7 @@ 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 /* spotless:off */ other is Void && 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 */ } /* spotless:off */ @@ -7999,10 +7319,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VoidLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "Void{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class VoidInitiatedLedgerEntry + class VoidInitiated private constructor( private val id: JsonField, private val amount: JsonField, @@ -8013,7 +7333,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val newBlockExpiryDate: JsonField, @@ -8048,9 +7368,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -8144,10 +7462,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("void_initiated") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -8265,15 +7588,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -8344,7 +7658,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [VoidInitiatedLedgerEntry]. + * Returns a mutable builder for constructing an instance of [VoidInitiated]. * * The following fields are required: * ```java @@ -8357,7 +7671,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -8369,7 +7682,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VoidInitiatedLedgerEntry]. */ + /** A builder for [VoidInitiated]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -8381,7 +7694,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void_initiated") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var newBlockExpiryDate: JsonField? = null @@ -8391,24 +7704,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = apply { - id = voidInitiatedLedgerEntry.id - amount = voidInitiatedLedgerEntry.amount - createdAt = voidInitiatedLedgerEntry.createdAt - creditBlock = voidInitiatedLedgerEntry.creditBlock - currency = voidInitiatedLedgerEntry.currency - customer = voidInitiatedLedgerEntry.customer - description = voidInitiatedLedgerEntry.description - endingBalance = voidInitiatedLedgerEntry.endingBalance - entryStatus = voidInitiatedLedgerEntry.entryStatus - entryType = voidInitiatedLedgerEntry.entryType - ledgerSequenceNumber = voidInitiatedLedgerEntry.ledgerSequenceNumber - metadata = voidInitiatedLedgerEntry.metadata - newBlockExpiryDate = voidInitiatedLedgerEntry.newBlockExpiryDate - startingBalance = voidInitiatedLedgerEntry.startingBalance - voidAmount = voidInitiatedLedgerEntry.voidAmount - voidReason = voidInitiatedLedgerEntry.voidReason - additionalProperties = voidInitiatedLedgerEntry.additionalProperties.toMutableMap() + internal fun from(voidInitiated: VoidInitiated) = apply { + id = voidInitiated.id + amount = voidInitiated.amount + createdAt = voidInitiated.createdAt + creditBlock = voidInitiated.creditBlock + currency = voidInitiated.currency + customer = voidInitiated.customer + description = voidInitiated.description + endingBalance = voidInitiated.endingBalance + entryStatus = voidInitiated.entryStatus + entryType = voidInitiated.entryType + ledgerSequenceNumber = voidInitiated.ledgerSequenceNumber + metadata = voidInitiated.metadata + newBlockExpiryDate = voidInitiated.newBlockExpiryDate + startingBalance = voidInitiated.startingBalance + voidAmount = voidInitiated.voidAmount + voidReason = voidInitiated.voidReason + additionalProperties = voidInitiated.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -8523,16 +7836,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void_initiated") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -8637,7 +7953,7 @@ private constructor( } /** - * Returns an immutable instance of [VoidInitiatedLedgerEntry]. + * Returns an immutable instance of [VoidInitiated]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -8652,7 +7968,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -8663,8 +7978,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VoidInitiatedLedgerEntry = - VoidInitiatedLedgerEntry( + fun build(): VoidInitiated = + VoidInitiated( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -8674,7 +7989,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("newBlockExpiryDate", newBlockExpiryDate), @@ -8687,7 +8002,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VoidInitiatedLedgerEntry = apply { + fun validate(): VoidInitiated = apply { if (validated) { return@apply } @@ -8701,7 +8016,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void_initiated")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -8736,7 +8055,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void_initiated")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + @@ -9338,129 +8657,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 VOID_INITIATED = of("void_initiated") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID_INITIATED - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID_INITIATED, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID_INITIATED -> Value.VOID_INITIATED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID_INITIATED -> Known.VOID_INITIATED - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -9575,7 +8771,7 @@ 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 /* spotless:off */ other is VoidInitiated && 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 */ } /* spotless:off */ @@ -9585,10 +8781,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VoidInitiatedLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "VoidInitiated{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class AmendmentLedgerEntry + class Amendment private constructor( private val id: JsonField, private val amount: JsonField, @@ -9599,7 +8795,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -9631,9 +8827,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -9715,10 +8909,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -9817,15 +9016,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -9868,7 +9058,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AmendmentLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Amendment]. * * The following fields are required: * ```java @@ -9881,7 +9071,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -9890,7 +9079,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmendmentLedgerEntry]. */ + /** A builder for [Amendment]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -9902,28 +9091,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("amendment") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amendmentLedgerEntry: AmendmentLedgerEntry) = apply { - id = amendmentLedgerEntry.id - amount = amendmentLedgerEntry.amount - createdAt = amendmentLedgerEntry.createdAt - creditBlock = amendmentLedgerEntry.creditBlock - currency = amendmentLedgerEntry.currency - customer = amendmentLedgerEntry.customer - description = amendmentLedgerEntry.description - endingBalance = amendmentLedgerEntry.endingBalance - entryStatus = amendmentLedgerEntry.entryStatus - entryType = amendmentLedgerEntry.entryType - ledgerSequenceNumber = amendmentLedgerEntry.ledgerSequenceNumber - metadata = amendmentLedgerEntry.metadata - startingBalance = amendmentLedgerEntry.startingBalance - additionalProperties = amendmentLedgerEntry.additionalProperties.toMutableMap() + internal fun from(amendment: Amendment) = apply { + id = amendment.id + amount = amendment.amount + createdAt = amendment.createdAt + creditBlock = amendment.creditBlock + currency = amendment.currency + customer = amendment.customer + description = amendment.description + endingBalance = amendment.endingBalance + entryStatus = amendment.entryStatus + entryType = amendment.entryType + ledgerSequenceNumber = amendment.ledgerSequenceNumber + metadata = amendment.metadata + startingBalance = amendment.startingBalance + additionalProperties = amendment.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -10038,16 +9227,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -10113,7 +9305,7 @@ private constructor( } /** - * Returns an immutable instance of [AmendmentLedgerEntry]. + * Returns an immutable instance of [Amendment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -10128,7 +9320,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -10136,8 +9327,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmendmentLedgerEntry = - AmendmentLedgerEntry( + fun build(): Amendment = + Amendment( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -10147,7 +9338,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -10157,7 +9348,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmendmentLedgerEntry = apply { + fun validate(): Amendment = apply { if (validated) { return@apply } @@ -10171,7 +9362,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("amendment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -10203,7 +9398,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("amendment")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -10802,129 +9997,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -11039,7 +10111,7 @@ 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 /* spotless:off */ other is Amendment && 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 */ } /* spotless:off */ @@ -11049,6 +10121,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmendmentLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "Amendment{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } } 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 5d118b31..876dcb8b 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 @@ -138,13 +138,13 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCreditLedgerCreateEntryParams private constructor( - private val customerId: String, + private val customerId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) fun body(): Body = body @@ -162,7 +162,6 @@ private constructor( * * The following fields are required: * ```java - * .customerId() * .body() * ``` */ @@ -188,120 +187,48 @@ private constructor( customerCreditLedgerCreateEntryParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) fun body(body: Body) = apply { this.body = body } - /** - * Alias for calling [body] with - * `Body.ofAddIncrementCreditLedgerEntryRequestParams(addIncrementCreditLedgerEntryRequestParams)`. - */ - fun body( - addIncrementCreditLedgerEntryRequestParams: - Body.AddIncrementCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams - ) - ) + /** Alias for calling [body] with `Body.ofIncrement(increment)`. */ + fun body(increment: Body.Increment) = body(Body.ofIncrement(increment)) /** * Alias for calling [body] with the following: * ```java - * Body.AddIncrementCreditLedgerEntryRequestParams.builder() - * .entryType(CustomerCreditLedgerCreateEntryParams.Body.AddIncrementCreditLedgerEntryRequestParams.EntryType.INCREMENT) + * Body.Increment.builder() * .amount(amount) * .build() * ``` */ - fun addIncrementCreditLedgerEntryRequestParamsBody(amount: Double) = - body( - Body.AddIncrementCreditLedgerEntryRequestParams.builder() - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .amount(amount) - .build() - ) + fun incrementBody(amount: Double) = body(Body.Increment.builder().amount(amount).build()) - /** - * Alias for calling [body] with - * `Body.ofAddDecrementCreditLedgerEntryRequestParams(addDecrementCreditLedgerEntryRequestParams)`. - */ - fun body( - addDecrementCreditLedgerEntryRequestParams: - Body.AddDecrementCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams - ) - ) + /** Alias for calling [body] with `Body.ofDecrement(decrement)`. */ + fun body(decrement: Body.Decrement) = body(Body.ofDecrement(decrement)) /** * Alias for calling [body] with the following: * ```java - * Body.AddDecrementCreditLedgerEntryRequestParams.builder() - * .entryType(CustomerCreditLedgerCreateEntryParams.Body.AddDecrementCreditLedgerEntryRequestParams.EntryType.DECREMENT) + * Body.Decrement.builder() * .amount(amount) * .build() * ``` */ - fun addDecrementCreditLedgerEntryRequestParamsBody(amount: Double) = - body( - Body.AddDecrementCreditLedgerEntryRequestParams.builder() - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddDecrementCreditLedgerEntryRequestParams - .EntryType - .DECREMENT - ) - .amount(amount) - .build() - ) + fun decrementBody(amount: Double) = body(Body.Decrement.builder().amount(amount).build()) - /** - * Alias for calling [body] with - * `Body.ofAddExpirationChangeCreditLedgerEntryRequestParams(addExpirationChangeCreditLedgerEntryRequestParams)`. - */ - fun body( - addExpirationChangeCreditLedgerEntryRequestParams: - Body.AddExpirationChangeCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams - ) - ) + /** Alias for calling [body] with `Body.ofExpirationChange(expirationChange)`. */ + fun body(expirationChange: Body.ExpirationChange) = + body(Body.ofExpirationChange(expirationChange)) - /** - * Alias for calling [body] with - * `Body.ofAddVoidCreditLedgerEntryRequestParams(addVoidCreditLedgerEntryRequestParams)`. - */ - fun body( - addVoidCreditLedgerEntryRequestParams: Body.AddVoidCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddVoidCreditLedgerEntryRequestParams(addVoidCreditLedgerEntryRequestParams) - ) + /** Alias for calling [body] with `Body.ofVoid(void_)`. */ + fun body(void_: Body.Void) = body(Body.ofVoid(void_)) - /** - * Alias for calling [body] with - * `Body.ofAddAmendmentCreditLedgerEntryRequestParams(addAmendmentCreditLedgerEntryRequestParams)`. - */ - fun body( - addAmendmentCreditLedgerEntryRequestParams: - Body.AddAmendmentCreditLedgerEntryRequestParams - ) = - body( - Body.ofAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams - ) - ) + /** Alias for calling [body] with `Body.ofAmendment(amendment)`. */ + fun body(amendment: Body.Amendment) = body(Body.ofAmendment(amendment)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -408,7 +335,6 @@ private constructor( * * The following fields are required: * ```java - * .customerId() * .body() * ``` * @@ -416,7 +342,7 @@ private constructor( */ fun build(): CustomerCreditLedgerCreateEntryParams = CustomerCreditLedgerCreateEntryParams( - checkRequired("customerId", customerId), + customerId, checkRequired("body", body), additionalHeaders.build(), additionalQueryParams.build(), @@ -427,7 +353,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } @@ -439,111 +365,53 @@ private constructor( @JsonSerialize(using = Body.Serializer::class) class Body private constructor( - private val addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams? = - null, - private val addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams? = - null, - private val addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams? = - null, - private val addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams? = - null, - private val addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams? = - null, + private val increment: Increment? = null, + private val decrement: Decrement? = null, + private val expirationChange: ExpirationChange? = null, + private val void_: Void? = null, + private val amendment: Amendment? = null, private val _json: JsonValue? = null, ) { - fun addIncrementCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addIncrementCreditLedgerEntryRequestParams) + fun increment(): Optional = Optional.ofNullable(increment) - fun addDecrementCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addDecrementCreditLedgerEntryRequestParams) + fun decrement(): Optional = Optional.ofNullable(decrement) - fun addExpirationChangeCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addExpirationChangeCreditLedgerEntryRequestParams) + fun expirationChange(): Optional = Optional.ofNullable(expirationChange) - fun addVoidCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addVoidCreditLedgerEntryRequestParams) + fun void_(): Optional = Optional.ofNullable(void_) - fun addAmendmentCreditLedgerEntryRequestParams(): - Optional = - Optional.ofNullable(addAmendmentCreditLedgerEntryRequestParams) + fun amendment(): Optional = Optional.ofNullable(amendment) - fun isAddIncrementCreditLedgerEntryRequestParams(): Boolean = - addIncrementCreditLedgerEntryRequestParams != null + fun isIncrement(): Boolean = increment != null - fun isAddDecrementCreditLedgerEntryRequestParams(): Boolean = - addDecrementCreditLedgerEntryRequestParams != null + fun isDecrement(): Boolean = decrement != null - fun isAddExpirationChangeCreditLedgerEntryRequestParams(): Boolean = - addExpirationChangeCreditLedgerEntryRequestParams != null + fun isExpirationChange(): Boolean = expirationChange != null - fun isAddVoidCreditLedgerEntryRequestParams(): Boolean = - addVoidCreditLedgerEntryRequestParams != null + fun isVoid(): Boolean = void_ != null - fun isAddAmendmentCreditLedgerEntryRequestParams(): Boolean = - addAmendmentCreditLedgerEntryRequestParams != null + fun isAmendment(): Boolean = amendment != null - fun asAddIncrementCreditLedgerEntryRequestParams(): - AddIncrementCreditLedgerEntryRequestParams = - addIncrementCreditLedgerEntryRequestParams.getOrThrow( - "addIncrementCreditLedgerEntryRequestParams" - ) + fun asIncrement(): Increment = increment.getOrThrow("increment") - fun asAddDecrementCreditLedgerEntryRequestParams(): - AddDecrementCreditLedgerEntryRequestParams = - addDecrementCreditLedgerEntryRequestParams.getOrThrow( - "addDecrementCreditLedgerEntryRequestParams" - ) + fun asDecrement(): Decrement = decrement.getOrThrow("decrement") - fun asAddExpirationChangeCreditLedgerEntryRequestParams(): - AddExpirationChangeCreditLedgerEntryRequestParams = - addExpirationChangeCreditLedgerEntryRequestParams.getOrThrow( - "addExpirationChangeCreditLedgerEntryRequestParams" - ) + fun asExpirationChange(): ExpirationChange = expirationChange.getOrThrow("expirationChange") - fun asAddVoidCreditLedgerEntryRequestParams(): AddVoidCreditLedgerEntryRequestParams = - addVoidCreditLedgerEntryRequestParams.getOrThrow( - "addVoidCreditLedgerEntryRequestParams" - ) + fun asVoid(): Void = void_.getOrThrow("void_") - fun asAddAmendmentCreditLedgerEntryRequestParams(): - AddAmendmentCreditLedgerEntryRequestParams = - addAmendmentCreditLedgerEntryRequestParams.getOrThrow( - "addAmendmentCreditLedgerEntryRequestParams" - ) + fun asAmendment(): Amendment = amendment.getOrThrow("amendment") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - addIncrementCreditLedgerEntryRequestParams != null -> - visitor.visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams - ) - addDecrementCreditLedgerEntryRequestParams != null -> - visitor.visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams - ) - addExpirationChangeCreditLedgerEntryRequestParams != null -> - visitor.visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams - ) - addVoidCreditLedgerEntryRequestParams != null -> - visitor.visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams - ) - addAmendmentCreditLedgerEntryRequestParams != null -> - visitor.visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams - ) + increment != null -> visitor.visitIncrement(increment) + decrement != null -> visitor.visitDecrement(decrement) + expirationChange != null -> visitor.visitExpirationChange(expirationChange) + void_ != null -> visitor.visitVoid(void_) + amendment != null -> visitor.visitAmendment(amendment) else -> visitor.unknown(_json) } @@ -556,38 +424,24 @@ private constructor( accept( object : Visitor { - override fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) { - addIncrementCreditLedgerEntryRequestParams.validate() + override fun visitIncrement(increment: Increment) { + increment.validate() } - override fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) { - addDecrementCreditLedgerEntryRequestParams.validate() + override fun visitDecrement(decrement: Decrement) { + decrement.validate() } - override fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) { - addExpirationChangeCreditLedgerEntryRequestParams.validate() + override fun visitExpirationChange(expirationChange: ExpirationChange) { + expirationChange.validate() } - override fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) { - addVoidCreditLedgerEntryRequestParams.validate() + override fun visitVoid(void_: Void) { + void_.validate() } - override fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) { - addAmendmentCreditLedgerEntryRequestParams.validate() + override fun visitAmendment(amendment: Amendment) { + amendment.validate() } } ) @@ -612,29 +466,16 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = addIncrementCreditLedgerEntryRequestParams.validity() - - override fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = addDecrementCreditLedgerEntryRequestParams.validity() - - override fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = addExpirationChangeCreditLedgerEntryRequestParams.validity() - - override fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = addVoidCreditLedgerEntryRequestParams.validity() - - override fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = addAmendmentCreditLedgerEntryRequestParams.validity() + override fun visitIncrement(increment: Increment) = increment.validity() + + override fun visitDecrement(decrement: Decrement) = decrement.validity() + + override fun visitExpirationChange(expirationChange: ExpirationChange) = + expirationChange.validity() + + override fun visitVoid(void_: Void) = void_.validity() + + override fun visitAmendment(amendment: Amendment) = amendment.validity() override fun unknown(json: JsonValue?) = 0 } @@ -645,101 +486,49 @@ private constructor( return true } - return /* spotless:off */ other is Body && addIncrementCreditLedgerEntryRequestParams == other.addIncrementCreditLedgerEntryRequestParams && addDecrementCreditLedgerEntryRequestParams == other.addDecrementCreditLedgerEntryRequestParams && addExpirationChangeCreditLedgerEntryRequestParams == other.addExpirationChangeCreditLedgerEntryRequestParams && addVoidCreditLedgerEntryRequestParams == other.addVoidCreditLedgerEntryRequestParams && addAmendmentCreditLedgerEntryRequestParams == other.addAmendmentCreditLedgerEntryRequestParams /* spotless:on */ + return /* spotless:off */ other is Body && increment == other.increment && decrement == other.decrement && expirationChange == other.expirationChange && void_ == other.void_ && amendment == other.amendment /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(addIncrementCreditLedgerEntryRequestParams, addDecrementCreditLedgerEntryRequestParams, addExpirationChangeCreditLedgerEntryRequestParams, addVoidCreditLedgerEntryRequestParams, addAmendmentCreditLedgerEntryRequestParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, void_, amendment) /* spotless:on */ override fun toString(): String = when { - addIncrementCreditLedgerEntryRequestParams != null -> - "Body{addIncrementCreditLedgerEntryRequestParams=$addIncrementCreditLedgerEntryRequestParams}" - addDecrementCreditLedgerEntryRequestParams != null -> - "Body{addDecrementCreditLedgerEntryRequestParams=$addDecrementCreditLedgerEntryRequestParams}" - addExpirationChangeCreditLedgerEntryRequestParams != null -> - "Body{addExpirationChangeCreditLedgerEntryRequestParams=$addExpirationChangeCreditLedgerEntryRequestParams}" - addVoidCreditLedgerEntryRequestParams != null -> - "Body{addVoidCreditLedgerEntryRequestParams=$addVoidCreditLedgerEntryRequestParams}" - addAmendmentCreditLedgerEntryRequestParams != null -> - "Body{addAmendmentCreditLedgerEntryRequestParams=$addAmendmentCreditLedgerEntryRequestParams}" + increment != null -> "Body{increment=$increment}" + decrement != null -> "Body{decrement=$decrement}" + expirationChange != null -> "Body{expirationChange=$expirationChange}" + void_ != null -> "Body{void_=$void_}" + amendment != null -> "Body{amendment=$amendment}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") } companion object { - @JvmStatic - fun ofAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = - Body( - addIncrementCreditLedgerEntryRequestParams = - addIncrementCreditLedgerEntryRequestParams - ) + @JvmStatic fun ofIncrement(increment: Increment) = Body(increment = increment) - @JvmStatic - fun ofAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = - Body( - addDecrementCreditLedgerEntryRequestParams = - addDecrementCreditLedgerEntryRequestParams - ) + @JvmStatic fun ofDecrement(decrement: Decrement) = Body(decrement = decrement) @JvmStatic - fun ofAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = - Body( - addExpirationChangeCreditLedgerEntryRequestParams = - addExpirationChangeCreditLedgerEntryRequestParams - ) + fun ofExpirationChange(expirationChange: ExpirationChange) = + Body(expirationChange = expirationChange) - @JvmStatic - fun ofAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = Body(addVoidCreditLedgerEntryRequestParams = addVoidCreditLedgerEntryRequestParams) + @JvmStatic fun ofVoid(void_: Void) = Body(void_ = void_) - @JvmStatic - fun ofAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = - Body( - addAmendmentCreditLedgerEntryRequestParams = - addAmendmentCreditLedgerEntryRequestParams - ) + @JvmStatic fun ofAmendment(amendment: Amendment) = Body(amendment = amendment) } /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ interface Visitor { - fun visitAddIncrementCreditLedgerEntryRequestParams( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ): T + fun visitIncrement(increment: Increment): T - fun visitAddDecrementCreditLedgerEntryRequestParams( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ): T + fun visitDecrement(decrement: Decrement): T - fun visitAddExpirationChangeCreditLedgerEntryRequestParams( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ): T + fun visitExpirationChange(expirationChange: ExpirationChange): T - fun visitAddVoidCreditLedgerEntryRequestParams( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ): T + fun visitVoid(void_: Void): T - fun visitAddAmendmentCreditLedgerEntryRequestParams( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ): T + fun visitAmendment(amendment: Amendment): T /** * Maps an unknown variant of [Body] to a value of type [T]. @@ -764,51 +553,29 @@ private constructor( when (entryType) { "increment" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body(addIncrementCreditLedgerEntryRequestParams = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(increment = it, _json = json) + } ?: Body(_json = json) } "decrement" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body(addDecrementCreditLedgerEntryRequestParams = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(decrement = it, _json = json) + } ?: Body(_json = json) } "expiration_change" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body( - addExpirationChangeCreditLedgerEntryRequestParams = it, - _json = json, - ) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(expirationChange = it, _json = json) + } ?: Body(_json = json) } "void" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(addVoidCreditLedgerEntryRequestParams = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(void_ = it, _json = json) + } ?: Body(_json = json) } "amendment" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body(addAmendmentCreditLedgerEntryRequestParams = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(amendment = it, _json = json) + } ?: Body(_json = json) } } @@ -824,28 +591,21 @@ private constructor( provider: SerializerProvider, ) { when { - value.addIncrementCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addIncrementCreditLedgerEntryRequestParams) - value.addDecrementCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addDecrementCreditLedgerEntryRequestParams) - value.addExpirationChangeCreditLedgerEntryRequestParams != null -> - generator.writeObject( - value.addExpirationChangeCreditLedgerEntryRequestParams - ) - value.addVoidCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addVoidCreditLedgerEntryRequestParams) - value.addAmendmentCreditLedgerEntryRequestParams != null -> - generator.writeObject(value.addAmendmentCreditLedgerEntryRequestParams) + value.increment != null -> generator.writeObject(value.increment) + value.decrement != null -> generator.writeObject(value.decrement) + value.expirationChange != null -> generator.writeObject(value.expirationChange) + value.void_ != null -> generator.writeObject(value.void_) + value.amendment != null -> generator.writeObject(value.amendment) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") } } } - class AddIncrementCreditLedgerEntryRequestParams + class Increment private constructor( private val amount: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val currency: JsonField, private val description: JsonField, private val effectiveDate: JsonField, @@ -861,9 +621,7 @@ private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -909,11 +667,15 @@ private constructor( fun amount(): Double = amount.getRequired("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). + * Expected to always return the following: + * ```java + * JsonValue.from("increment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -990,16 +752,6 @@ private constructor( */ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [currency]. * @@ -1083,23 +835,21 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddIncrementCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [Increment]. * * The following fields are required: * ```java * .amount() - * .entryType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddIncrementCreditLedgerEntryRequestParams]. */ + /** A builder for [Increment]. */ class Builder internal constructor() { private var amount: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("increment") private var currency: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var effectiveDate: JsonField = JsonMissing.of() @@ -1110,22 +860,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addIncrementCreditLedgerEntryRequestParams: - AddIncrementCreditLedgerEntryRequestParams - ) = apply { - amount = addIncrementCreditLedgerEntryRequestParams.amount - entryType = addIncrementCreditLedgerEntryRequestParams.entryType - currency = addIncrementCreditLedgerEntryRequestParams.currency - description = addIncrementCreditLedgerEntryRequestParams.description - effectiveDate = addIncrementCreditLedgerEntryRequestParams.effectiveDate - expiryDate = addIncrementCreditLedgerEntryRequestParams.expiryDate - invoiceSettings = addIncrementCreditLedgerEntryRequestParams.invoiceSettings - metadata = addIncrementCreditLedgerEntryRequestParams.metadata - perUnitCostBasis = addIncrementCreditLedgerEntryRequestParams.perUnitCostBasis - additionalProperties = - addIncrementCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() + internal fun from(increment: Increment) = apply { + amount = increment.amount + entryType = increment.entryType + currency = increment.currency + description = increment.description + effectiveDate = increment.effectiveDate + expiryDate = increment.expiryDate + invoiceSettings = increment.invoiceSettings + metadata = increment.metadata + perUnitCostBasis = increment.perUnitCostBasis + additionalProperties = increment.additionalProperties.toMutableMap() } /** @@ -1143,18 +888,19 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("increment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -1330,22 +1076,21 @@ private constructor( } /** - * Returns an immutable instance of [AddIncrementCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [Increment]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .amount() - * .entryType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddIncrementCreditLedgerEntryRequestParams = - AddIncrementCreditLedgerEntryRequestParams( + fun build(): Increment = + Increment( checkRequired("amount", amount), - checkRequired("entryType", entryType), + entryType, currency, description, effectiveDate, @@ -1359,13 +1104,17 @@ private constructor( private var validated: Boolean = false - fun validate(): AddIncrementCreditLedgerEntryRequestParams = apply { + fun validate(): Increment = apply { if (validated) { return@apply } amount() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("increment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } currency() description() effectiveDate() @@ -1393,7 +1142,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("increment")) 1 else 0 } + (if (currency.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (if (effectiveDate.asKnown().isPresent) 1 else 0) + @@ -1402,131 +1151,6 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (perUnitCostBasis.asKnown().isPresent) 1 else 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as @@ -1960,7 +1584,7 @@ private constructor( return true } - return /* spotless:off */ other is AddIncrementCreditLedgerEntryRequestParams && 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 /* 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 */ } /* spotless:off */ @@ -1970,13 +1594,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddIncrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" + "Increment{amount=$amount, entryType=$entryType, currency=$currency, description=$description, effectiveDate=$effectiveDate, expiryDate=$expiryDate, invoiceSettings=$invoiceSettings, metadata=$metadata, perUnitCostBasis=$perUnitCostBasis, additionalProperties=$additionalProperties}" } - class AddDecrementCreditLedgerEntryRequestParams + class Decrement private constructor( private val amount: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val currency: JsonField, private val description: JsonField, private val metadata: JsonField, @@ -1988,9 +1612,7 @@ private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -2013,11 +1635,15 @@ private constructor( fun amount(): Double = amount.getRequired("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). + * Expected to always return the following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -2055,16 +1681,6 @@ private constructor( */ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [currency]. * @@ -2108,41 +1724,34 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddDecrementCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [Decrement]. * * The following fields are required: * ```java * .amount() - * .entryType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddDecrementCreditLedgerEntryRequestParams]. */ + /** A builder for [Decrement]. */ class Builder internal constructor() { private var amount: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("decrement") private var currency: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addDecrementCreditLedgerEntryRequestParams: - AddDecrementCreditLedgerEntryRequestParams - ) = apply { - amount = addDecrementCreditLedgerEntryRequestParams.amount - entryType = addDecrementCreditLedgerEntryRequestParams.entryType - currency = addDecrementCreditLedgerEntryRequestParams.currency - description = addDecrementCreditLedgerEntryRequestParams.description - metadata = addDecrementCreditLedgerEntryRequestParams.metadata - additionalProperties = - addDecrementCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() + internal fun from(decrement: Decrement) = apply { + amount = decrement.amount + entryType = decrement.entryType + currency = decrement.currency + description = decrement.description + metadata = decrement.metadata + additionalProperties = decrement.additionalProperties.toMutableMap() } /** @@ -2160,18 +1769,19 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -2256,22 +1866,21 @@ private constructor( } /** - * Returns an immutable instance of [AddDecrementCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [Decrement]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .amount() - * .entryType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddDecrementCreditLedgerEntryRequestParams = - AddDecrementCreditLedgerEntryRequestParams( + fun build(): Decrement = + Decrement( checkRequired("amount", amount), - checkRequired("entryType", entryType), + entryType, currency, description, metadata, @@ -2281,13 +1890,17 @@ private constructor( private var validated: Boolean = false - fun validate(): AddDecrementCreditLedgerEntryRequestParams = apply { + fun validate(): Decrement = apply { if (validated) { return@apply } amount() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("decrement")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } currency() description() metadata().ifPresent { it.validate() } @@ -2311,168 +1924,43 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("decrement")) 1 else 0 } + (if (currency.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + class Metadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + fun toBuilder() = Builder().from(this) companion object { - @JvmField val DECREMENT = of("decrement") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - 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) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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() + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -2557,7 +2045,7 @@ private constructor( return true } - return /* spotless:off */ other is AddDecrementCreditLedgerEntryRequestParams && amount == other.amount && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + 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 */ } /* spotless:off */ @@ -2567,12 +2055,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddDecrementCreditLedgerEntryRequestParams{amount=$amount, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + "Decrement{amount=$amount, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } - class AddExpirationChangeCreditLedgerEntryRequestParams + class ExpirationChange private constructor( - private val entryType: JsonField, + private val entryType: JsonValue, private val expiryDate: JsonField, private val targetExpiryDate: JsonField, private val amount: JsonField, @@ -2585,9 +2073,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("expiry_date") @ExcludeMissing expiryDate: JsonField = JsonMissing.of(), @@ -2622,11 +2108,15 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * An ISO 8601 format date that identifies the origination credit block to expire @@ -2693,16 +2183,6 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("metadata") - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [expiryDate]. * @@ -2780,12 +2260,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddExpirationChangeCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [ExpirationChange]. * * The following fields are required: * ```java - * .entryType() * .expiryDate() * .targetExpiryDate() * ``` @@ -2793,10 +2271,10 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AddExpirationChangeCreditLedgerEntryRequestParams]. */ + /** A builder for [ExpirationChange]. */ class Builder internal constructor() { - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("expiration_change") private var expiryDate: JsonField? = null private var targetExpiryDate: JsonField? = null private var amount: JsonField = JsonMissing.of() @@ -2807,36 +2285,31 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addExpirationChangeCreditLedgerEntryRequestParams: - AddExpirationChangeCreditLedgerEntryRequestParams - ) = apply { - entryType = addExpirationChangeCreditLedgerEntryRequestParams.entryType - expiryDate = addExpirationChangeCreditLedgerEntryRequestParams.expiryDate - targetExpiryDate = - addExpirationChangeCreditLedgerEntryRequestParams.targetExpiryDate - amount = addExpirationChangeCreditLedgerEntryRequestParams.amount - blockId = addExpirationChangeCreditLedgerEntryRequestParams.blockId - currency = addExpirationChangeCreditLedgerEntryRequestParams.currency - description = addExpirationChangeCreditLedgerEntryRequestParams.description - metadata = addExpirationChangeCreditLedgerEntryRequestParams.metadata - additionalProperties = - addExpirationChangeCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() + internal fun from(expirationChange: ExpirationChange) = apply { + entryType = expirationChange.entryType + expiryDate = expirationChange.expiryDate + targetExpiryDate = expirationChange.targetExpiryDate + amount = expirationChange.amount + blockId = expirationChange.blockId + currency = expirationChange.currency + description = expirationChange.description + metadata = expirationChange.metadata + additionalProperties = expirationChange.additionalProperties.toMutableMap() } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * An ISO 8601 format date that identifies the origination credit block to expire @@ -3004,23 +2477,21 @@ private constructor( } /** - * Returns an immutable instance of - * [AddExpirationChangeCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [ExpirationChange]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .entryType() * .expiryDate() * .targetExpiryDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddExpirationChangeCreditLedgerEntryRequestParams = - AddExpirationChangeCreditLedgerEntryRequestParams( - checkRequired("entryType", entryType), + fun build(): ExpirationChange = + ExpirationChange( + entryType, checkRequired("expiryDate", expiryDate), checkRequired("targetExpiryDate", targetExpiryDate), amount, @@ -3034,12 +2505,16 @@ private constructor( private var validated: Boolean = false - fun validate(): AddExpirationChangeCreditLedgerEntryRequestParams = apply { + fun validate(): ExpirationChange = apply { if (validated) { return@apply } - entryType().validate() + _entryType().let { + if (it != JsonValue.from("expiration_change")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } expiryDate() targetExpiryDate() amount() @@ -3066,7 +2541,7 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("expiration_change")) 1 else 0 } + (if (expiryDate.asKnown().isPresent) 1 else 0) + (if (targetExpiryDate.asKnown().isPresent) 1 else 0) + (if (amount.asKnown().isPresent) 1 else 0) + @@ -3075,131 +2550,6 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -3316,7 +2666,7 @@ private constructor( return true } - return /* spotless:off */ other is AddExpirationChangeCreditLedgerEntryRequestParams && entryType == other.entryType && expiryDate == other.expiryDate && targetExpiryDate == other.targetExpiryDate && amount == other.amount && blockId == other.blockId && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ExpirationChange && entryType == other.entryType && expiryDate == other.expiryDate && targetExpiryDate == other.targetExpiryDate && amount == other.amount && blockId == other.blockId && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3326,14 +2676,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddExpirationChangeCreditLedgerEntryRequestParams{entryType=$entryType, expiryDate=$expiryDate, targetExpiryDate=$targetExpiryDate, amount=$amount, blockId=$blockId, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + "ExpirationChange{entryType=$entryType, expiryDate=$expiryDate, targetExpiryDate=$targetExpiryDate, amount=$amount, blockId=$blockId, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } - class AddVoidCreditLedgerEntryRequestParams + class Void private constructor( private val amount: JsonField, private val blockId: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val currency: JsonField, private val description: JsonField, private val metadata: JsonField, @@ -3349,9 +2699,7 @@ private constructor( @JsonProperty("block_id") @ExcludeMissing blockId: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -3395,11 +2743,15 @@ private constructor( fun blockId(): String = blockId.getRequired("block_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). + * Expected to always return the following: + * ```java + * JsonValue.from("void") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -3452,16 +2804,6 @@ private constructor( */ @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [currency]. * @@ -3515,25 +2857,23 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddVoidCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [Void]. * * The following fields are required: * ```java * .amount() * .blockId() - * .entryType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddVoidCreditLedgerEntryRequestParams]. */ + /** A builder for [Void]. */ class Builder internal constructor() { private var amount: JsonField? = null private var blockId: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void") private var currency: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() @@ -3541,18 +2881,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addVoidCreditLedgerEntryRequestParams: AddVoidCreditLedgerEntryRequestParams - ) = apply { - amount = addVoidCreditLedgerEntryRequestParams.amount - blockId = addVoidCreditLedgerEntryRequestParams.blockId - entryType = addVoidCreditLedgerEntryRequestParams.entryType - currency = addVoidCreditLedgerEntryRequestParams.currency - description = addVoidCreditLedgerEntryRequestParams.description - metadata = addVoidCreditLedgerEntryRequestParams.metadata - voidReason = addVoidCreditLedgerEntryRequestParams.voidReason - additionalProperties = - addVoidCreditLedgerEntryRequestParams.additionalProperties.toMutableMap() + internal fun from(void_: Void) = apply { + amount = void_.amount + blockId = void_.blockId + entryType = void_.entryType + currency = void_.currency + description = void_.description + metadata = void_.metadata + voidReason = void_.voidReason + additionalProperties = void_.additionalProperties.toMutableMap() } /** @@ -3582,18 +2919,19 @@ private constructor( */ fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -3697,7 +3035,7 @@ private constructor( } /** - * Returns an immutable instance of [AddVoidCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [Void]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3705,16 +3043,15 @@ private constructor( * ```java * .amount() * .blockId() - * .entryType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddVoidCreditLedgerEntryRequestParams = - AddVoidCreditLedgerEntryRequestParams( + fun build(): Void = + Void( checkRequired("amount", amount), checkRequired("blockId", blockId), - checkRequired("entryType", entryType), + entryType, currency, description, metadata, @@ -3725,14 +3062,18 @@ private constructor( private var validated: Boolean = false - fun validate(): AddVoidCreditLedgerEntryRequestParams = apply { + fun validate(): Void = apply { if (validated) { return@apply } amount() blockId() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } currency() description() metadata().ifPresent { it.validate() } @@ -3758,137 +3099,12 @@ private constructor( internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + (if (blockId.asKnown().isPresent) 1 else 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void")) 1 else 0 } + (if (currency.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (voidReason.asKnown().getOrNull()?.validity() ?: 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -4132,7 +3348,7 @@ private constructor( return true } - return /* spotless:off */ other is AddVoidCreditLedgerEntryRequestParams && 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 /* 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 */ } /* spotless:off */ @@ -4142,14 +3358,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddVoidCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "Void{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class AddAmendmentCreditLedgerEntryRequestParams + class Amendment private constructor( private val amount: JsonField, private val blockId: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val currency: JsonField, private val description: JsonField, private val metadata: JsonField, @@ -4164,9 +3380,7 @@ private constructor( @JsonProperty("block_id") @ExcludeMissing blockId: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -4198,11 +3412,15 @@ private constructor( fun blockId(): String = blockId.getRequired("block_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). + * Expected to always return the following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -4247,16 +3465,6 @@ private constructor( */ @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [currency]. * @@ -4300,44 +3508,37 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AddAmendmentCreditLedgerEntryRequestParams]. + * Returns a mutable builder for constructing an instance of [Amendment]. * * The following fields are required: * ```java * .amount() * .blockId() - * .entryType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AddAmendmentCreditLedgerEntryRequestParams]. */ + /** A builder for [Amendment]. */ class Builder internal constructor() { private var amount: JsonField? = null private var blockId: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("amendment") private var currency: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - addAmendmentCreditLedgerEntryRequestParams: - AddAmendmentCreditLedgerEntryRequestParams - ) = apply { - amount = addAmendmentCreditLedgerEntryRequestParams.amount - blockId = addAmendmentCreditLedgerEntryRequestParams.blockId - entryType = addAmendmentCreditLedgerEntryRequestParams.entryType - currency = addAmendmentCreditLedgerEntryRequestParams.currency - description = addAmendmentCreditLedgerEntryRequestParams.description - metadata = addAmendmentCreditLedgerEntryRequestParams.metadata - additionalProperties = - addAmendmentCreditLedgerEntryRequestParams.additionalProperties - .toMutableMap() + internal fun from(amendment: Amendment) = apply { + amount = amendment.amount + blockId = amendment.blockId + entryType = amendment.entryType + currency = amendment.currency + description = amendment.description + metadata = amendment.metadata + additionalProperties = amendment.additionalProperties.toMutableMap() } /** @@ -4367,18 +3568,19 @@ private constructor( */ fun blockId(blockId: JsonField) = apply { this.blockId = blockId } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun entryType(entryType: JsonField) = apply { - this.entryType = entryType - } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -4463,7 +3665,7 @@ private constructor( } /** - * Returns an immutable instance of [AddAmendmentCreditLedgerEntryRequestParams]. + * Returns an immutable instance of [Amendment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4471,16 +3673,15 @@ private constructor( * ```java * .amount() * .blockId() - * .entryType() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AddAmendmentCreditLedgerEntryRequestParams = - AddAmendmentCreditLedgerEntryRequestParams( + fun build(): Amendment = + Amendment( checkRequired("amount", amount), checkRequired("blockId", blockId), - checkRequired("entryType", entryType), + entryType, currency, description, metadata, @@ -4490,14 +3691,18 @@ private constructor( private var validated: Boolean = false - fun validate(): AddAmendmentCreditLedgerEntryRequestParams = apply { + fun validate(): Amendment = apply { if (validated) { return@apply } amount() blockId() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("amendment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } currency() description() metadata().ifPresent { it.validate() } @@ -4522,136 +3727,11 @@ private constructor( internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + (if (blockId.asKnown().isPresent) 1 else 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("amendment")) 1 else 0 } + (if (currency.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -4768,7 +3848,7 @@ private constructor( return true } - return /* spotless:off */ other is AddAmendmentCreditLedgerEntryRequestParams && amount == other.amount && blockId == other.blockId && entryType == other.entryType && currency == other.currency && description == other.description && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + 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 */ } /* spotless:off */ @@ -4778,7 +3858,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AddAmendmentCreditLedgerEntryRequestParams{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" + "Amendment{amount=$amount, blockId=$blockId, entryType=$entryType, currency=$currency, description=$description, metadata=$metadata, additionalProperties=$additionalProperties}" } } 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 72c2ad8e..fa95ecc9 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 @@ -38,84 +38,69 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = CustomerCreditLedgerCreateEntryResponse.Serializer::class) class CustomerCreditLedgerCreateEntryResponse private constructor( - private val incrementLedgerEntry: IncrementLedgerEntry? = null, - private val decrementLedgerEntry: DecrementLedgerEntry? = null, - private val expirationChangeLedgerEntry: ExpirationChangeLedgerEntry? = null, - private val creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry? = null, - private val voidLedgerEntry: VoidLedgerEntry? = null, - private val voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry? = null, - private val amendmentLedgerEntry: AmendmentLedgerEntry? = null, + private val increment: Increment? = null, + private val decrement: Decrement? = null, + private val expirationChange: ExpirationChange? = null, + private val creditBlockExpiry: CreditBlockExpiry? = null, + private val void_: Void? = null, + private val voidInitiated: VoidInitiated? = null, + private val amendment: Amendment? = null, private val _json: JsonValue? = null, ) { - fun incrementLedgerEntry(): Optional = - Optional.ofNullable(incrementLedgerEntry) + fun increment(): Optional = Optional.ofNullable(increment) - fun decrementLedgerEntry(): Optional = - Optional.ofNullable(decrementLedgerEntry) + fun decrement(): Optional = Optional.ofNullable(decrement) - fun expirationChangeLedgerEntry(): Optional = - Optional.ofNullable(expirationChangeLedgerEntry) + fun expirationChange(): Optional = Optional.ofNullable(expirationChange) - fun creditBlockExpiryLedgerEntry(): Optional = - Optional.ofNullable(creditBlockExpiryLedgerEntry) + fun creditBlockExpiry(): Optional = Optional.ofNullable(creditBlockExpiry) - fun voidLedgerEntry(): Optional = Optional.ofNullable(voidLedgerEntry) + fun void_(): Optional = Optional.ofNullable(void_) - fun voidInitiatedLedgerEntry(): Optional = - Optional.ofNullable(voidInitiatedLedgerEntry) + fun voidInitiated(): Optional = Optional.ofNullable(voidInitiated) - fun amendmentLedgerEntry(): Optional = - Optional.ofNullable(amendmentLedgerEntry) + fun amendment(): Optional = Optional.ofNullable(amendment) - fun isIncrementLedgerEntry(): Boolean = incrementLedgerEntry != null + fun isIncrement(): Boolean = increment != null - fun isDecrementLedgerEntry(): Boolean = decrementLedgerEntry != null + fun isDecrement(): Boolean = decrement != null - fun isExpirationChangeLedgerEntry(): Boolean = expirationChangeLedgerEntry != null + fun isExpirationChange(): Boolean = expirationChange != null - fun isCreditBlockExpiryLedgerEntry(): Boolean = creditBlockExpiryLedgerEntry != null + fun isCreditBlockExpiry(): Boolean = creditBlockExpiry != null - fun isVoidLedgerEntry(): Boolean = voidLedgerEntry != null + fun isVoid(): Boolean = void_ != null - fun isVoidInitiatedLedgerEntry(): Boolean = voidInitiatedLedgerEntry != null + fun isVoidInitiated(): Boolean = voidInitiated != null - fun isAmendmentLedgerEntry(): Boolean = amendmentLedgerEntry != null + fun isAmendment(): Boolean = amendment != null - fun asIncrementLedgerEntry(): IncrementLedgerEntry = - incrementLedgerEntry.getOrThrow("incrementLedgerEntry") + fun asIncrement(): Increment = increment.getOrThrow("increment") - fun asDecrementLedgerEntry(): DecrementLedgerEntry = - decrementLedgerEntry.getOrThrow("decrementLedgerEntry") + fun asDecrement(): Decrement = decrement.getOrThrow("decrement") - fun asExpirationChangeLedgerEntry(): ExpirationChangeLedgerEntry = - expirationChangeLedgerEntry.getOrThrow("expirationChangeLedgerEntry") + fun asExpirationChange(): ExpirationChange = expirationChange.getOrThrow("expirationChange") - fun asCreditBlockExpiryLedgerEntry(): CreditBlockExpiryLedgerEntry = - creditBlockExpiryLedgerEntry.getOrThrow("creditBlockExpiryLedgerEntry") + fun asCreditBlockExpiry(): CreditBlockExpiry = creditBlockExpiry.getOrThrow("creditBlockExpiry") - fun asVoidLedgerEntry(): VoidLedgerEntry = voidLedgerEntry.getOrThrow("voidLedgerEntry") + fun asVoid(): Void = void_.getOrThrow("void_") - fun asVoidInitiatedLedgerEntry(): VoidInitiatedLedgerEntry = - voidInitiatedLedgerEntry.getOrThrow("voidInitiatedLedgerEntry") + fun asVoidInitiated(): VoidInitiated = voidInitiated.getOrThrow("voidInitiated") - fun asAmendmentLedgerEntry(): AmendmentLedgerEntry = - amendmentLedgerEntry.getOrThrow("amendmentLedgerEntry") + fun asAmendment(): Amendment = amendment.getOrThrow("amendment") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) - decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) - expirationChangeLedgerEntry != null -> - visitor.visitExpirationChangeLedgerEntry(expirationChangeLedgerEntry) - creditBlockExpiryLedgerEntry != null -> - visitor.visitCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry) - voidLedgerEntry != null -> visitor.visitVoidLedgerEntry(voidLedgerEntry) - voidInitiatedLedgerEntry != null -> - visitor.visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry) - amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) + increment != null -> visitor.visitIncrement(increment) + decrement != null -> visitor.visitDecrement(decrement) + expirationChange != null -> visitor.visitExpirationChange(expirationChange) + creditBlockExpiry != null -> visitor.visitCreditBlockExpiry(creditBlockExpiry) + void_ != null -> visitor.visitVoid(void_) + voidInitiated != null -> visitor.visitVoidInitiated(voidInitiated) + amendment != null -> visitor.visitAmendment(amendment) else -> visitor.unknown(_json) } @@ -128,38 +113,32 @@ private constructor( accept( object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) { - incrementLedgerEntry.validate() + override fun visitIncrement(increment: Increment) { + increment.validate() } - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) { - decrementLedgerEntry.validate() + override fun visitDecrement(decrement: Decrement) { + decrement.validate() } - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) { - expirationChangeLedgerEntry.validate() + override fun visitExpirationChange(expirationChange: ExpirationChange) { + expirationChange.validate() } - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) { - creditBlockExpiryLedgerEntry.validate() + override fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) { + creditBlockExpiry.validate() } - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) { - voidLedgerEntry.validate() + override fun visitVoid(void_: Void) { + void_.validate() } - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) { - voidInitiatedLedgerEntry.validate() + override fun visitVoidInitiated(voidInitiated: VoidInitiated) { + voidInitiated.validate() } - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) { - amendmentLedgerEntry.validate() + override fun visitAmendment(amendment: Amendment) { + amendment.validate() } } ) @@ -183,29 +162,22 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - incrementLedgerEntry.validity() + override fun visitIncrement(increment: Increment) = increment.validity() - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - decrementLedgerEntry.validity() + override fun visitDecrement(decrement: Decrement) = decrement.validity() - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = expirationChangeLedgerEntry.validity() + override fun visitExpirationChange(expirationChange: ExpirationChange) = + expirationChange.validity() - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = creditBlockExpiryLedgerEntry.validity() + override fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) = + creditBlockExpiry.validity() - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - voidLedgerEntry.validity() + override fun visitVoid(void_: Void) = void_.validity() - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) = voidInitiatedLedgerEntry.validity() + override fun visitVoidInitiated(voidInitiated: VoidInitiated) = + voidInitiated.validity() - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - amendmentLedgerEntry.validity() + override fun visitAmendment(amendment: Amendment) = amendment.validity() override fun unknown(json: JsonValue?) = 0 } @@ -216,27 +188,23 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerCreateEntryResponse && incrementLedgerEntry == other.incrementLedgerEntry && decrementLedgerEntry == other.decrementLedgerEntry && expirationChangeLedgerEntry == other.expirationChangeLedgerEntry && creditBlockExpiryLedgerEntry == other.creditBlockExpiryLedgerEntry && voidLedgerEntry == other.voidLedgerEntry && voidInitiatedLedgerEntry == other.voidInitiatedLedgerEntry && amendmentLedgerEntry == other.amendmentLedgerEntry /* spotless:on */ + 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 */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementLedgerEntry, decrementLedgerEntry, expirationChangeLedgerEntry, creditBlockExpiryLedgerEntry, voidLedgerEntry, voidInitiatedLedgerEntry, amendmentLedgerEntry) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, creditBlockExpiry, void_, voidInitiated, amendment) /* spotless:on */ override fun toString(): String = when { - incrementLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{incrementLedgerEntry=$incrementLedgerEntry}" - decrementLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{decrementLedgerEntry=$decrementLedgerEntry}" - expirationChangeLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{expirationChangeLedgerEntry=$expirationChangeLedgerEntry}" - creditBlockExpiryLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{creditBlockExpiryLedgerEntry=$creditBlockExpiryLedgerEntry}" - voidLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{voidLedgerEntry=$voidLedgerEntry}" - voidInitiatedLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{voidInitiatedLedgerEntry=$voidInitiatedLedgerEntry}" - amendmentLedgerEntry != null -> - "CustomerCreditLedgerCreateEntryResponse{amendmentLedgerEntry=$amendmentLedgerEntry}" + increment != null -> "CustomerCreditLedgerCreateEntryResponse{increment=$increment}" + decrement != null -> "CustomerCreditLedgerCreateEntryResponse{decrement=$decrement}" + expirationChange != null -> + "CustomerCreditLedgerCreateEntryResponse{expirationChange=$expirationChange}" + creditBlockExpiry != null -> + "CustomerCreditLedgerCreateEntryResponse{creditBlockExpiry=$creditBlockExpiry}" + void_ != null -> "CustomerCreditLedgerCreateEntryResponse{void_=$void_}" + voidInitiated != null -> + "CustomerCreditLedgerCreateEntryResponse{voidInitiated=$voidInitiated}" + amendment != null -> "CustomerCreditLedgerCreateEntryResponse{amendment=$amendment}" _json != null -> "CustomerCreditLedgerCreateEntryResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid CustomerCreditLedgerCreateEntryResponse") } @@ -244,42 +212,30 @@ private constructor( companion object { @JvmStatic - fun ofIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse(incrementLedgerEntry = incrementLedgerEntry) + fun ofIncrement(increment: Increment) = + CustomerCreditLedgerCreateEntryResponse(increment = increment) @JvmStatic - fun ofDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse(decrementLedgerEntry = decrementLedgerEntry) + fun ofDecrement(decrement: Decrement) = + CustomerCreditLedgerCreateEntryResponse(decrement = decrement) @JvmStatic - fun ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = - CustomerCreditLedgerCreateEntryResponse( - expirationChangeLedgerEntry = expirationChangeLedgerEntry - ) + fun ofExpirationChange(expirationChange: ExpirationChange) = + CustomerCreditLedgerCreateEntryResponse(expirationChange = expirationChange) @JvmStatic - fun ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = - CustomerCreditLedgerCreateEntryResponse( - creditBlockExpiryLedgerEntry = creditBlockExpiryLedgerEntry - ) + fun ofCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) = + CustomerCreditLedgerCreateEntryResponse(creditBlockExpiry = creditBlockExpiry) - @JvmStatic - fun ofVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse(voidLedgerEntry = voidLedgerEntry) + @JvmStatic fun ofVoid(void_: Void) = CustomerCreditLedgerCreateEntryResponse(void_ = void_) @JvmStatic - fun ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse( - voidInitiatedLedgerEntry = voidInitiatedLedgerEntry - ) + fun ofVoidInitiated(voidInitiated: VoidInitiated) = + CustomerCreditLedgerCreateEntryResponse(voidInitiated = voidInitiated) @JvmStatic - fun ofAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - CustomerCreditLedgerCreateEntryResponse(amendmentLedgerEntry = amendmentLedgerEntry) + fun ofAmendment(amendment: Amendment) = + CustomerCreditLedgerCreateEntryResponse(amendment = amendment) } /** @@ -288,23 +244,19 @@ private constructor( */ interface Visitor { - fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry): T + fun visitIncrement(increment: Increment): T - fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry): T + fun visitDecrement(decrement: Decrement): T - fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ): T + fun visitExpirationChange(expirationChange: ExpirationChange): T - fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ): T + fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry): T - fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry): T + fun visitVoid(void_: Void): T - fun visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry): T + fun visitVoidInitiated(voidInitiated: VoidInitiated): T - fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry): T + fun visitAmendment(amendment: Amendment): T /** * Maps an unknown variant of [CustomerCreditLedgerCreateEntryResponse] to a value of type @@ -335,58 +287,41 @@ private constructor( when (entryType) { "increment" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerCreateEntryResponse( - incrementLedgerEntry = it, - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse(increment = it, _json = json) } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "decrement" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerCreateEntryResponse( - decrementLedgerEntry = it, - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse(decrement = it, _json = json) } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "expiration_change" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - CustomerCreditLedgerCreateEntryResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse(expirationChange = it, _json = json) + } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "credit_block_expiry" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - CustomerCreditLedgerCreateEntryResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse( + creditBlockExpiry = it, + _json = json, + ) + } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "void" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerCreateEntryResponse(voidLedgerEntry = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse(void_ = it, _json = json) } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "void_initiated" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerCreateEntryResponse( - voidInitiatedLedgerEntry = it, - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse(voidInitiated = it, _json = json) } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } "amendment" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerCreateEntryResponse( - amendmentLedgerEntry = it, - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerCreateEntryResponse(amendment = it, _json = json) } ?: CustomerCreditLedgerCreateEntryResponse(_json = json) } } @@ -406,19 +341,13 @@ private constructor( provider: SerializerProvider, ) { when { - value.incrementLedgerEntry != null -> - generator.writeObject(value.incrementLedgerEntry) - value.decrementLedgerEntry != null -> - generator.writeObject(value.decrementLedgerEntry) - value.expirationChangeLedgerEntry != null -> - generator.writeObject(value.expirationChangeLedgerEntry) - value.creditBlockExpiryLedgerEntry != null -> - generator.writeObject(value.creditBlockExpiryLedgerEntry) - value.voidLedgerEntry != null -> generator.writeObject(value.voidLedgerEntry) - value.voidInitiatedLedgerEntry != null -> - generator.writeObject(value.voidInitiatedLedgerEntry) - value.amendmentLedgerEntry != null -> - generator.writeObject(value.amendmentLedgerEntry) + value.increment != null -> generator.writeObject(value.increment) + value.decrement != null -> generator.writeObject(value.decrement) + value.expirationChange != null -> generator.writeObject(value.expirationChange) + value.creditBlockExpiry != null -> generator.writeObject(value.creditBlockExpiry) + value.void_ != null -> generator.writeObject(value.void_) + value.voidInitiated != null -> generator.writeObject(value.voidInitiated) + value.amendment != null -> generator.writeObject(value.amendment) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid CustomerCreditLedgerCreateEntryResponse") @@ -426,7 +355,7 @@ private constructor( } } - class IncrementLedgerEntry + class Increment private constructor( private val id: JsonField, private val amount: JsonField, @@ -437,7 +366,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -469,9 +398,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -553,10 +480,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("increment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -655,15 +587,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -706,7 +629,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [IncrementLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Increment]. * * The following fields are required: * ```java @@ -719,7 +642,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -728,7 +650,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [IncrementLedgerEntry]. */ + /** A builder for [Increment]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -740,28 +662,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("increment") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(incrementLedgerEntry: IncrementLedgerEntry) = apply { - id = incrementLedgerEntry.id - amount = incrementLedgerEntry.amount - createdAt = incrementLedgerEntry.createdAt - creditBlock = incrementLedgerEntry.creditBlock - currency = incrementLedgerEntry.currency - customer = incrementLedgerEntry.customer - description = incrementLedgerEntry.description - endingBalance = incrementLedgerEntry.endingBalance - entryStatus = incrementLedgerEntry.entryStatus - entryType = incrementLedgerEntry.entryType - ledgerSequenceNumber = incrementLedgerEntry.ledgerSequenceNumber - metadata = incrementLedgerEntry.metadata - startingBalance = incrementLedgerEntry.startingBalance - additionalProperties = incrementLedgerEntry.additionalProperties.toMutableMap() + internal fun from(increment: Increment) = apply { + id = increment.id + amount = increment.amount + createdAt = increment.createdAt + creditBlock = increment.creditBlock + currency = increment.currency + customer = increment.customer + description = increment.description + endingBalance = increment.endingBalance + entryStatus = increment.entryStatus + entryType = increment.entryType + ledgerSequenceNumber = increment.ledgerSequenceNumber + metadata = increment.metadata + startingBalance = increment.startingBalance + additionalProperties = increment.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -876,16 +798,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("increment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -951,7 +876,7 @@ private constructor( } /** - * Returns an immutable instance of [IncrementLedgerEntry]. + * Returns an immutable instance of [Increment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -966,7 +891,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -974,8 +898,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): IncrementLedgerEntry = - IncrementLedgerEntry( + fun build(): Increment = + Increment( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -985,7 +909,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -995,7 +919,7 @@ private constructor( private var validated: Boolean = false - fun validate(): IncrementLedgerEntry = apply { + fun validate(): Increment = apply { if (validated) { return@apply } @@ -1009,7 +933,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("increment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -1041,7 +969,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("increment")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -1640,129 +1568,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -1877,7 +1682,7 @@ 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 && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Increment && 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 */ } /* spotless:off */ @@ -1887,10 +1692,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "IncrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "Increment{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class DecrementLedgerEntry + class Decrement private constructor( private val id: JsonField, private val amount: JsonField, @@ -1901,7 +1706,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -1936,9 +1741,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -2028,10 +1831,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -2148,15 +1956,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -2220,7 +2019,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DecrementLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Decrement]. * * The following fields are required: * ```java @@ -2233,7 +2032,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -2242,7 +2040,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DecrementLedgerEntry]. */ + /** A builder for [Decrement]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -2254,7 +2052,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("decrement") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null @@ -2264,24 +2062,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(decrementLedgerEntry: DecrementLedgerEntry) = apply { - id = decrementLedgerEntry.id - amount = decrementLedgerEntry.amount - createdAt = decrementLedgerEntry.createdAt - creditBlock = decrementLedgerEntry.creditBlock - currency = decrementLedgerEntry.currency - customer = decrementLedgerEntry.customer - description = decrementLedgerEntry.description - endingBalance = decrementLedgerEntry.endingBalance - entryStatus = decrementLedgerEntry.entryStatus - entryType = decrementLedgerEntry.entryType - ledgerSequenceNumber = decrementLedgerEntry.ledgerSequenceNumber - metadata = decrementLedgerEntry.metadata - startingBalance = decrementLedgerEntry.startingBalance - eventId = decrementLedgerEntry.eventId - invoiceId = decrementLedgerEntry.invoiceId - priceId = decrementLedgerEntry.priceId - additionalProperties = decrementLedgerEntry.additionalProperties.toMutableMap() + internal fun from(decrement: Decrement) = apply { + id = decrement.id + amount = decrement.amount + createdAt = decrement.createdAt + creditBlock = decrement.creditBlock + currency = decrement.currency + customer = decrement.customer + description = decrement.description + endingBalance = decrement.endingBalance + entryStatus = decrement.entryStatus + entryType = decrement.entryType + ledgerSequenceNumber = decrement.ledgerSequenceNumber + metadata = decrement.metadata + startingBalance = decrement.startingBalance + eventId = decrement.eventId + invoiceId = decrement.invoiceId + priceId = decrement.priceId + additionalProperties = decrement.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2396,16 +2194,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -2513,7 +2314,7 @@ private constructor( } /** - * Returns an immutable instance of [DecrementLedgerEntry]. + * Returns an immutable instance of [Decrement]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2528,7 +2329,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -2536,8 +2336,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DecrementLedgerEntry = - DecrementLedgerEntry( + fun build(): Decrement = + Decrement( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -2547,7 +2347,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -2560,7 +2360,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DecrementLedgerEntry = apply { + fun validate(): Decrement = apply { if (validated) { return@apply } @@ -2574,7 +2374,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("decrement")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -2609,7 +2413,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("decrement")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) + @@ -3211,170 +3015,47 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * 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 + ) { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - companion object { + fun toBuilder() = Builder().from(this) - @JvmField val DECREMENT = of("decrement") + companion object { - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DECREMENT -> Value.DECREMENT - else -> Value._UNKNOWN + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @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 putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } fun putAllAdditionalProperties(additionalProperties: Map) = @@ -3448,7 +3129,7 @@ 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 /* spotless:off */ other is Decrement && 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 */ } /* spotless:off */ @@ -3458,10 +3139,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DecrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" + "Decrement{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" } - class ExpirationChangeLedgerEntry + class ExpirationChange private constructor( private val id: JsonField, private val amount: JsonField, @@ -3472,7 +3153,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val newBlockExpiryDate: JsonField, @@ -3505,9 +3186,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -3593,10 +3272,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -3702,15 +3386,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -3763,8 +3438,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExpirationChangeLedgerEntry]. + * Returns a mutable builder for constructing an instance of [ExpirationChange]. * * The following fields are required: * ```java @@ -3777,7 +3451,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -3787,7 +3460,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExpirationChangeLedgerEntry]. */ + /** A builder for [ExpirationChange]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -3799,7 +3472,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("expiration_change") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var newBlockExpiryDate: JsonField? = null @@ -3807,23 +3480,22 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(expirationChangeLedgerEntry: ExpirationChangeLedgerEntry) = apply { - id = expirationChangeLedgerEntry.id - amount = expirationChangeLedgerEntry.amount - createdAt = expirationChangeLedgerEntry.createdAt - creditBlock = expirationChangeLedgerEntry.creditBlock - currency = expirationChangeLedgerEntry.currency - customer = expirationChangeLedgerEntry.customer - description = expirationChangeLedgerEntry.description - endingBalance = expirationChangeLedgerEntry.endingBalance - entryStatus = expirationChangeLedgerEntry.entryStatus - entryType = expirationChangeLedgerEntry.entryType - ledgerSequenceNumber = expirationChangeLedgerEntry.ledgerSequenceNumber - metadata = expirationChangeLedgerEntry.metadata - newBlockExpiryDate = expirationChangeLedgerEntry.newBlockExpiryDate - startingBalance = expirationChangeLedgerEntry.startingBalance - additionalProperties = - expirationChangeLedgerEntry.additionalProperties.toMutableMap() + internal fun from(expirationChange: ExpirationChange) = apply { + id = expirationChange.id + amount = expirationChange.amount + createdAt = expirationChange.createdAt + creditBlock = expirationChange.creditBlock + currency = expirationChange.currency + customer = expirationChange.customer + description = expirationChange.description + endingBalance = expirationChange.endingBalance + entryStatus = expirationChange.entryStatus + entryType = expirationChange.entryType + ledgerSequenceNumber = expirationChange.ledgerSequenceNumber + metadata = expirationChange.metadata + newBlockExpiryDate = expirationChange.newBlockExpiryDate + startingBalance = expirationChange.startingBalance + additionalProperties = expirationChange.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3938,16 +3610,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -4034,7 +3709,7 @@ private constructor( } /** - * Returns an immutable instance of [ExpirationChangeLedgerEntry]. + * Returns an immutable instance of [ExpirationChange]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4049,7 +3724,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -4058,8 +3732,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): ExpirationChangeLedgerEntry = - ExpirationChangeLedgerEntry( + fun build(): ExpirationChange = + ExpirationChange( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -4069,7 +3743,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("newBlockExpiryDate", newBlockExpiryDate), @@ -4080,7 +3754,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExpirationChangeLedgerEntry = apply { + fun validate(): ExpirationChange = apply { if (validated) { return@apply } @@ -4094,7 +3768,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("expiration_change")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -4127,7 +3805,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("expiration_change")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + @@ -4727,129 +4405,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -4964,7 +4519,7 @@ 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 /* spotless:off */ other is ExpirationChange && 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 */ } /* spotless:off */ @@ -4974,10 +4529,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExpirationChangeLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "ExpirationChange{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class CreditBlockExpiryLedgerEntry + class CreditBlockExpiry private constructor( private val id: JsonField, private val amount: JsonField, @@ -4988,7 +4543,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -5020,9 +4575,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -5104,10 +4657,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("credit_block_expiry") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -5206,15 +4764,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -5257,8 +4806,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CreditBlockExpiryLedgerEntry]. + * Returns a mutable builder for constructing an instance of [CreditBlockExpiry]. * * The following fields are required: * ```java @@ -5271,7 +4819,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -5280,7 +4827,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CreditBlockExpiryLedgerEntry]. */ + /** A builder for [CreditBlockExpiry]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -5292,29 +4839,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("credit_block_expiry") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry) = apply { - id = creditBlockExpiryLedgerEntry.id - amount = creditBlockExpiryLedgerEntry.amount - createdAt = creditBlockExpiryLedgerEntry.createdAt - creditBlock = creditBlockExpiryLedgerEntry.creditBlock - currency = creditBlockExpiryLedgerEntry.currency - customer = creditBlockExpiryLedgerEntry.customer - description = creditBlockExpiryLedgerEntry.description - endingBalance = creditBlockExpiryLedgerEntry.endingBalance - entryStatus = creditBlockExpiryLedgerEntry.entryStatus - entryType = creditBlockExpiryLedgerEntry.entryType - ledgerSequenceNumber = creditBlockExpiryLedgerEntry.ledgerSequenceNumber - metadata = creditBlockExpiryLedgerEntry.metadata - startingBalance = creditBlockExpiryLedgerEntry.startingBalance - additionalProperties = - creditBlockExpiryLedgerEntry.additionalProperties.toMutableMap() + internal fun from(creditBlockExpiry: CreditBlockExpiry) = apply { + id = creditBlockExpiry.id + amount = creditBlockExpiry.amount + createdAt = creditBlockExpiry.createdAt + creditBlock = creditBlockExpiry.creditBlock + currency = creditBlockExpiry.currency + customer = creditBlockExpiry.customer + description = creditBlockExpiry.description + endingBalance = creditBlockExpiry.endingBalance + entryStatus = creditBlockExpiry.entryStatus + entryType = creditBlockExpiry.entryType + ledgerSequenceNumber = creditBlockExpiry.ledgerSequenceNumber + metadata = creditBlockExpiry.metadata + startingBalance = creditBlockExpiry.startingBalance + additionalProperties = creditBlockExpiry.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -5429,16 +4975,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("credit_block_expiry") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -5504,7 +5053,7 @@ private constructor( } /** - * Returns an immutable instance of [CreditBlockExpiryLedgerEntry]. + * Returns an immutable instance of [CreditBlockExpiry]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -5519,7 +5068,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -5527,8 +5075,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CreditBlockExpiryLedgerEntry = - CreditBlockExpiryLedgerEntry( + fun build(): CreditBlockExpiry = + CreditBlockExpiry( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -5538,7 +5086,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -5548,7 +5096,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CreditBlockExpiryLedgerEntry = apply { + fun validate(): CreditBlockExpiry = apply { if (validated) { return@apply } @@ -5562,7 +5110,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("credit_block_expiry")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -5594,7 +5146,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("credit_block_expiry")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -6193,129 +5745,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 CREDIT_BLOCK_EXPIRY = of("credit_block_expiry") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - CREDIT_BLOCK_EXPIRY - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREDIT_BLOCK_EXPIRY, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CREDIT_BLOCK_EXPIRY -> Value.CREDIT_BLOCK_EXPIRY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREDIT_BLOCK_EXPIRY -> Known.CREDIT_BLOCK_EXPIRY - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -6430,7 +5859,7 @@ 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 /* spotless:off */ other is CreditBlockExpiry && 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 */ } /* spotless:off */ @@ -6440,10 +5869,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CreditBlockExpiryLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "CreditBlockExpiry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class VoidLedgerEntry + class Void private constructor( private val id: JsonField, private val amount: JsonField, @@ -6454,7 +5883,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -6488,9 +5917,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -6580,10 +6007,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("void") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -6694,15 +6126,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -6763,7 +6186,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [VoidLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Void]. * * The following fields are required: * ```java @@ -6776,7 +6199,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -6787,7 +6209,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VoidLedgerEntry]. */ + /** A builder for [Void]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -6799,7 +6221,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null @@ -6808,23 +6230,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(voidLedgerEntry: VoidLedgerEntry) = apply { - id = voidLedgerEntry.id - amount = voidLedgerEntry.amount - createdAt = voidLedgerEntry.createdAt - creditBlock = voidLedgerEntry.creditBlock - currency = voidLedgerEntry.currency - customer = voidLedgerEntry.customer - description = voidLedgerEntry.description - endingBalance = voidLedgerEntry.endingBalance - entryStatus = voidLedgerEntry.entryStatus - entryType = voidLedgerEntry.entryType - ledgerSequenceNumber = voidLedgerEntry.ledgerSequenceNumber - metadata = voidLedgerEntry.metadata - startingBalance = voidLedgerEntry.startingBalance - voidAmount = voidLedgerEntry.voidAmount - voidReason = voidLedgerEntry.voidReason - additionalProperties = voidLedgerEntry.additionalProperties.toMutableMap() + internal fun from(void_: Void) = apply { + id = void_.id + amount = void_.amount + createdAt = void_.createdAt + creditBlock = void_.creditBlock + currency = void_.currency + customer = void_.customer + description = void_.description + endingBalance = void_.endingBalance + entryStatus = void_.entryStatus + entryType = void_.entryType + ledgerSequenceNumber = void_.ledgerSequenceNumber + metadata = void_.metadata + startingBalance = void_.startingBalance + voidAmount = void_.voidAmount + voidReason = void_.voidReason + additionalProperties = void_.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -6939,16 +6361,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -7039,7 +6464,7 @@ private constructor( } /** - * Returns an immutable instance of [VoidLedgerEntry]. + * Returns an immutable instance of [Void]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7054,7 +6479,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -7064,8 +6488,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VoidLedgerEntry = - VoidLedgerEntry( + fun build(): Void = + Void( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -7075,7 +6499,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -7087,7 +6511,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VoidLedgerEntry = apply { + fun validate(): Void = apply { if (validated) { return@apply } @@ -7101,7 +6525,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -7135,7 +6563,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) + @@ -7680,131 +7108,8 @@ private constructor( fun known(): Known = when (this) { COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryStatus = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") + PENDING -> Known.PENDING + else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") } /** @@ -7821,7 +7126,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EntryType = apply { + fun validate(): EntryStatus = apply { if (validated) { return@apply } @@ -7851,7 +7156,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -7973,7 +7278,7 @@ 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 /* spotless:off */ other is Void && 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 */ } /* spotless:off */ @@ -7983,10 +7288,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VoidLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "Void{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class VoidInitiatedLedgerEntry + class VoidInitiated private constructor( private val id: JsonField, private val amount: JsonField, @@ -7997,7 +7302,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val newBlockExpiryDate: JsonField, @@ -8032,9 +7337,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -8128,10 +7431,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("void_initiated") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -8249,15 +7557,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -8328,7 +7627,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [VoidInitiatedLedgerEntry]. + * Returns a mutable builder for constructing an instance of [VoidInitiated]. * * The following fields are required: * ```java @@ -8341,7 +7640,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -8353,7 +7651,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VoidInitiatedLedgerEntry]. */ + /** A builder for [VoidInitiated]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -8365,7 +7663,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void_initiated") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var newBlockExpiryDate: JsonField? = null @@ -8375,24 +7673,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = apply { - id = voidInitiatedLedgerEntry.id - amount = voidInitiatedLedgerEntry.amount - createdAt = voidInitiatedLedgerEntry.createdAt - creditBlock = voidInitiatedLedgerEntry.creditBlock - currency = voidInitiatedLedgerEntry.currency - customer = voidInitiatedLedgerEntry.customer - description = voidInitiatedLedgerEntry.description - endingBalance = voidInitiatedLedgerEntry.endingBalance - entryStatus = voidInitiatedLedgerEntry.entryStatus - entryType = voidInitiatedLedgerEntry.entryType - ledgerSequenceNumber = voidInitiatedLedgerEntry.ledgerSequenceNumber - metadata = voidInitiatedLedgerEntry.metadata - newBlockExpiryDate = voidInitiatedLedgerEntry.newBlockExpiryDate - startingBalance = voidInitiatedLedgerEntry.startingBalance - voidAmount = voidInitiatedLedgerEntry.voidAmount - voidReason = voidInitiatedLedgerEntry.voidReason - additionalProperties = voidInitiatedLedgerEntry.additionalProperties.toMutableMap() + internal fun from(voidInitiated: VoidInitiated) = apply { + id = voidInitiated.id + amount = voidInitiated.amount + createdAt = voidInitiated.createdAt + creditBlock = voidInitiated.creditBlock + currency = voidInitiated.currency + customer = voidInitiated.customer + description = voidInitiated.description + endingBalance = voidInitiated.endingBalance + entryStatus = voidInitiated.entryStatus + entryType = voidInitiated.entryType + ledgerSequenceNumber = voidInitiated.ledgerSequenceNumber + metadata = voidInitiated.metadata + newBlockExpiryDate = voidInitiated.newBlockExpiryDate + startingBalance = voidInitiated.startingBalance + voidAmount = voidInitiated.voidAmount + voidReason = voidInitiated.voidReason + additionalProperties = voidInitiated.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -8507,16 +7805,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void_initiated") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -8621,7 +7922,7 @@ private constructor( } /** - * Returns an immutable instance of [VoidInitiatedLedgerEntry]. + * Returns an immutable instance of [VoidInitiated]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -8636,7 +7937,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -8647,8 +7947,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VoidInitiatedLedgerEntry = - VoidInitiatedLedgerEntry( + fun build(): VoidInitiated = + VoidInitiated( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -8658,7 +7958,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("newBlockExpiryDate", newBlockExpiryDate), @@ -8671,7 +7971,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VoidInitiatedLedgerEntry = apply { + fun validate(): VoidInitiated = apply { if (validated) { return@apply } @@ -8685,7 +7985,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void_initiated")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -8720,7 +8024,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void_initiated")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + @@ -9322,129 +8626,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 VOID_INITIATED = of("void_initiated") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID_INITIATED - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID_INITIATED, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID_INITIATED -> Value.VOID_INITIATED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID_INITIATED -> Known.VOID_INITIATED - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -9559,7 +8740,7 @@ 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 /* spotless:off */ other is VoidInitiated && 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 */ } /* spotless:off */ @@ -9569,10 +8750,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VoidInitiatedLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "VoidInitiated{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class AmendmentLedgerEntry + class Amendment private constructor( private val id: JsonField, private val amount: JsonField, @@ -9583,7 +8764,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -9615,9 +8796,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -9699,10 +8878,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -9801,15 +8985,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -9852,7 +9027,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AmendmentLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Amendment]. * * The following fields are required: * ```java @@ -9865,7 +9040,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -9874,7 +9048,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmendmentLedgerEntry]. */ + /** A builder for [Amendment]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -9886,28 +9060,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("amendment") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amendmentLedgerEntry: AmendmentLedgerEntry) = apply { - id = amendmentLedgerEntry.id - amount = amendmentLedgerEntry.amount - createdAt = amendmentLedgerEntry.createdAt - creditBlock = amendmentLedgerEntry.creditBlock - currency = amendmentLedgerEntry.currency - customer = amendmentLedgerEntry.customer - description = amendmentLedgerEntry.description - endingBalance = amendmentLedgerEntry.endingBalance - entryStatus = amendmentLedgerEntry.entryStatus - entryType = amendmentLedgerEntry.entryType - ledgerSequenceNumber = amendmentLedgerEntry.ledgerSequenceNumber - metadata = amendmentLedgerEntry.metadata - startingBalance = amendmentLedgerEntry.startingBalance - additionalProperties = amendmentLedgerEntry.additionalProperties.toMutableMap() + internal fun from(amendment: Amendment) = apply { + id = amendment.id + amount = amendment.amount + createdAt = amendment.createdAt + creditBlock = amendment.creditBlock + currency = amendment.currency + customer = amendment.customer + description = amendment.description + endingBalance = amendment.endingBalance + entryStatus = amendment.entryStatus + entryType = amendment.entryType + ledgerSequenceNumber = amendment.ledgerSequenceNumber + metadata = amendment.metadata + startingBalance = amendment.startingBalance + additionalProperties = amendment.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -10022,16 +9196,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -10097,7 +9274,7 @@ private constructor( } /** - * Returns an immutable instance of [AmendmentLedgerEntry]. + * Returns an immutable instance of [Amendment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -10112,7 +9289,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -10120,8 +9296,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmendmentLedgerEntry = - AmendmentLedgerEntry( + fun build(): Amendment = + Amendment( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -10131,7 +9307,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -10141,7 +9317,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmendmentLedgerEntry = apply { + fun validate(): Amendment = apply { if (validated) { return@apply } @@ -10155,7 +9331,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("amendment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -10187,7 +9367,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("amendment")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -10786,129 +9966,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -11023,7 +10080,7 @@ 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 /* spotless:off */ other is Amendment && 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 */ } /* spotless:off */ @@ -11033,6 +10090,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmendmentLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "Amendment{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } } 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 a791b9c6..bc5f132e 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.credits.LedgerService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [LedgerService.listByExternalId] */ @@ -16,7 +16,7 @@ private constructor( private val service: LedgerService, private val params: CustomerCreditLedgerListByExternalIdParams, private val response: CustomerCreditLedgerListByExternalIdPageResponse, -) { +) : Page { /** * Delegates to [CustomerCreditLedgerListByExternalIdPageResponse], but gracefully handles @@ -36,31 +36,23 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditLedgerListByExternalIdParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.listByExternalId(it) } + override fun nextPage(): CustomerCreditLedgerListByExternalIdPage = + service.listByExternalId(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CustomerCreditLedgerListByExternalIdParams = params @@ -136,26 +128,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CustomerCreditLedgerListByExternalIdPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 ce9a3b86..880a2a3a 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.credits.LedgerServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [LedgerServiceAsync.listByExternalId] */ class CustomerCreditLedgerListByExternalIdPageAsync private constructor( private val service: LedgerServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CustomerCreditLedgerListByExternalIdParams, private val response: CustomerCreditLedgerListByExternalIdPageResponse, -) { +) : PageAsync { /** * Delegates to [CustomerCreditLedgerListByExternalIdPageResponse], but gracefully handles @@ -37,33 +39,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditLedgerListByExternalIdParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.listByExternalId(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.listByExternalId(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CustomerCreditLedgerListByExternalIdParams = params @@ -82,6 +75,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -93,6 +87,7 @@ private constructor( class Builder internal constructor() { private var service: LedgerServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CustomerCreditLedgerListByExternalIdParams? = null private var response: CustomerCreditLedgerListByExternalIdPageResponse? = null @@ -102,12 +97,18 @@ private constructor( CustomerCreditLedgerListByExternalIdPageAsync ) = apply { service = customerCreditLedgerListByExternalIdPageAsync.service + streamHandlerExecutor = + customerCreditLedgerListByExternalIdPageAsync.streamHandlerExecutor params = customerCreditLedgerListByExternalIdPageAsync.params response = customerCreditLedgerListByExternalIdPageAsync.response } fun service(service: LedgerServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CustomerCreditLedgerListByExternalIdParams) = apply { this.params = params @@ -126,6 +127,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -135,52 +137,22 @@ private constructor( fun build(): CustomerCreditLedgerListByExternalIdPageAsync = CustomerCreditLedgerListByExternalIdPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CustomerCreditLedgerListByExternalIdPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (CustomerCreditLedgerListByExternalIdResponse) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList( - executor: Executor - ): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CustomerCreditLedgerListByExternalIdPageAsync{service=$service, params=$params, response=$response}" + "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 22f89788..ab3f2d31 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 @@ -141,91 +141,60 @@ private constructor( /** * Alias for calling [addData] with - * `CustomerCreditLedgerListByExternalIdResponse.ofIncrementLedgerEntry(incrementLedgerEntry)`. + * `CustomerCreditLedgerListByExternalIdResponse.ofIncrement(increment)`. */ - fun addData( - incrementLedgerEntry: CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - ) = - addData( - CustomerCreditLedgerListByExternalIdResponse.ofIncrementLedgerEntry( - incrementLedgerEntry - ) - ) + fun addData(increment: CustomerCreditLedgerListByExternalIdResponse.Increment) = + addData(CustomerCreditLedgerListByExternalIdResponse.ofIncrement(increment)) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListByExternalIdResponse.ofDecrementLedgerEntry(decrementLedgerEntry)`. + * `CustomerCreditLedgerListByExternalIdResponse.ofDecrement(decrement)`. */ - fun addData( - decrementLedgerEntry: CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry - ) = - addData( - CustomerCreditLedgerListByExternalIdResponse.ofDecrementLedgerEntry( - decrementLedgerEntry - ) - ) + fun addData(decrement: CustomerCreditLedgerListByExternalIdResponse.Decrement) = + addData(CustomerCreditLedgerListByExternalIdResponse.ofDecrement(decrement)) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListByExternalIdResponse.ofExpirationChangeLedgerEntry(expirationChangeLedgerEntry)`. + * `CustomerCreditLedgerListByExternalIdResponse.ofExpirationChange(expirationChange)`. */ fun addData( - expirationChangeLedgerEntry: - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry + expirationChange: CustomerCreditLedgerListByExternalIdResponse.ExpirationChange ) = addData( - CustomerCreditLedgerListByExternalIdResponse.ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry - ) + CustomerCreditLedgerListByExternalIdResponse.ofExpirationChange(expirationChange) ) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListByExternalIdResponse.ofCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry)`. + * `CustomerCreditLedgerListByExternalIdResponse.ofCreditBlockExpiry(creditBlockExpiry)`. */ fun addData( - creditBlockExpiryLedgerEntry: - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry + creditBlockExpiry: CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry ) = addData( - CustomerCreditLedgerListByExternalIdResponse.ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry - ) + CustomerCreditLedgerListByExternalIdResponse.ofCreditBlockExpiry(creditBlockExpiry) ) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListByExternalIdResponse.ofVoidLedgerEntry(voidLedgerEntry)`. + * `CustomerCreditLedgerListByExternalIdResponse.ofVoid(void_)`. */ - fun addData(voidLedgerEntry: CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry) = - addData(CustomerCreditLedgerListByExternalIdResponse.ofVoidLedgerEntry(voidLedgerEntry)) + fun addData(void_: CustomerCreditLedgerListByExternalIdResponse.Void) = + addData(CustomerCreditLedgerListByExternalIdResponse.ofVoid(void_)) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListByExternalIdResponse.ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry)`. + * `CustomerCreditLedgerListByExternalIdResponse.ofVoidInitiated(voidInitiated)`. */ - fun addData( - voidInitiatedLedgerEntry: - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry - ) = - addData( - CustomerCreditLedgerListByExternalIdResponse.ofVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry - ) - ) + fun addData(voidInitiated: CustomerCreditLedgerListByExternalIdResponse.VoidInitiated) = + addData(CustomerCreditLedgerListByExternalIdResponse.ofVoidInitiated(voidInitiated)) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListByExternalIdResponse.ofAmendmentLedgerEntry(amendmentLedgerEntry)`. + * `CustomerCreditLedgerListByExternalIdResponse.ofAmendment(amendment)`. */ - fun addData( - amendmentLedgerEntry: CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry - ) = - addData( - CustomerCreditLedgerListByExternalIdResponse.ofAmendmentLedgerEntry( - amendmentLedgerEntry - ) - ) + fun addData(amendment: CustomerCreditLedgerListByExternalIdResponse.Amendment) = + addData(CustomerCreditLedgerListByExternalIdResponse.ofAmendment(amendment)) fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) 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 2271ced0..8dd1b841 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 @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException @@ -95,7 +94,7 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCreditLedgerListByExternalIdParams private constructor( - private val externalCustomerId: String, + private val externalCustomerId: String?, private val createdAtGt: OffsetDateTime?, private val createdAtGte: OffsetDateTime?, private val createdAtLt: OffsetDateTime?, @@ -110,7 +109,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun externalCustomerId(): String = externalCustomerId + fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) fun createdAtGt(): Optional = Optional.ofNullable(createdAtGt) @@ -146,14 +145,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerCreditLedgerListByExternalIdParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerCreditLedgerListByExternalIdParams]. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -196,10 +192,16 @@ private constructor( customerCreditLedgerListByExternalIdParams.additionalQueryParams.toBuilder() } - fun externalCustomerId(externalCustomerId: String) = apply { + fun externalCustomerId(externalCustomerId: String?) = apply { this.externalCustomerId = externalCustomerId } + /** + * Alias for calling [Builder.externalCustomerId] with `externalCustomerId.orElse(null)`. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.getOrNull()) + fun createdAtGt(createdAtGt: OffsetDateTime?) = apply { this.createdAtGt = createdAtGt } /** Alias for calling [Builder.createdAtGt] with `createdAtGt.orElse(null)`. */ @@ -370,17 +372,10 @@ private constructor( * Returns an immutable instance of [CustomerCreditLedgerListByExternalIdParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerCreditLedgerListByExternalIdParams = CustomerCreditLedgerListByExternalIdParams( - checkRequired("externalCustomerId", externalCustomerId), + externalCustomerId, createdAtGt, createdAtGte, createdAtLt, @@ -398,7 +393,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalCustomerId + 0 -> externalCustomerId ?: "" else -> "" } 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 9ac44913..bca8107b 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 @@ -38,84 +38,69 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = CustomerCreditLedgerListByExternalIdResponse.Serializer::class) class CustomerCreditLedgerListByExternalIdResponse private constructor( - private val incrementLedgerEntry: IncrementLedgerEntry? = null, - private val decrementLedgerEntry: DecrementLedgerEntry? = null, - private val expirationChangeLedgerEntry: ExpirationChangeLedgerEntry? = null, - private val creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry? = null, - private val voidLedgerEntry: VoidLedgerEntry? = null, - private val voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry? = null, - private val amendmentLedgerEntry: AmendmentLedgerEntry? = null, + private val increment: Increment? = null, + private val decrement: Decrement? = null, + private val expirationChange: ExpirationChange? = null, + private val creditBlockExpiry: CreditBlockExpiry? = null, + private val void_: Void? = null, + private val voidInitiated: VoidInitiated? = null, + private val amendment: Amendment? = null, private val _json: JsonValue? = null, ) { - fun incrementLedgerEntry(): Optional = - Optional.ofNullable(incrementLedgerEntry) + fun increment(): Optional = Optional.ofNullable(increment) - fun decrementLedgerEntry(): Optional = - Optional.ofNullable(decrementLedgerEntry) + fun decrement(): Optional = Optional.ofNullable(decrement) - fun expirationChangeLedgerEntry(): Optional = - Optional.ofNullable(expirationChangeLedgerEntry) + fun expirationChange(): Optional = Optional.ofNullable(expirationChange) - fun creditBlockExpiryLedgerEntry(): Optional = - Optional.ofNullable(creditBlockExpiryLedgerEntry) + fun creditBlockExpiry(): Optional = Optional.ofNullable(creditBlockExpiry) - fun voidLedgerEntry(): Optional = Optional.ofNullable(voidLedgerEntry) + fun void_(): Optional = Optional.ofNullable(void_) - fun voidInitiatedLedgerEntry(): Optional = - Optional.ofNullable(voidInitiatedLedgerEntry) + fun voidInitiated(): Optional = Optional.ofNullable(voidInitiated) - fun amendmentLedgerEntry(): Optional = - Optional.ofNullable(amendmentLedgerEntry) + fun amendment(): Optional = Optional.ofNullable(amendment) - fun isIncrementLedgerEntry(): Boolean = incrementLedgerEntry != null + fun isIncrement(): Boolean = increment != null - fun isDecrementLedgerEntry(): Boolean = decrementLedgerEntry != null + fun isDecrement(): Boolean = decrement != null - fun isExpirationChangeLedgerEntry(): Boolean = expirationChangeLedgerEntry != null + fun isExpirationChange(): Boolean = expirationChange != null - fun isCreditBlockExpiryLedgerEntry(): Boolean = creditBlockExpiryLedgerEntry != null + fun isCreditBlockExpiry(): Boolean = creditBlockExpiry != null - fun isVoidLedgerEntry(): Boolean = voidLedgerEntry != null + fun isVoid(): Boolean = void_ != null - fun isVoidInitiatedLedgerEntry(): Boolean = voidInitiatedLedgerEntry != null + fun isVoidInitiated(): Boolean = voidInitiated != null - fun isAmendmentLedgerEntry(): Boolean = amendmentLedgerEntry != null + fun isAmendment(): Boolean = amendment != null - fun asIncrementLedgerEntry(): IncrementLedgerEntry = - incrementLedgerEntry.getOrThrow("incrementLedgerEntry") + fun asIncrement(): Increment = increment.getOrThrow("increment") - fun asDecrementLedgerEntry(): DecrementLedgerEntry = - decrementLedgerEntry.getOrThrow("decrementLedgerEntry") + fun asDecrement(): Decrement = decrement.getOrThrow("decrement") - fun asExpirationChangeLedgerEntry(): ExpirationChangeLedgerEntry = - expirationChangeLedgerEntry.getOrThrow("expirationChangeLedgerEntry") + fun asExpirationChange(): ExpirationChange = expirationChange.getOrThrow("expirationChange") - fun asCreditBlockExpiryLedgerEntry(): CreditBlockExpiryLedgerEntry = - creditBlockExpiryLedgerEntry.getOrThrow("creditBlockExpiryLedgerEntry") + fun asCreditBlockExpiry(): CreditBlockExpiry = creditBlockExpiry.getOrThrow("creditBlockExpiry") - fun asVoidLedgerEntry(): VoidLedgerEntry = voidLedgerEntry.getOrThrow("voidLedgerEntry") + fun asVoid(): Void = void_.getOrThrow("void_") - fun asVoidInitiatedLedgerEntry(): VoidInitiatedLedgerEntry = - voidInitiatedLedgerEntry.getOrThrow("voidInitiatedLedgerEntry") + fun asVoidInitiated(): VoidInitiated = voidInitiated.getOrThrow("voidInitiated") - fun asAmendmentLedgerEntry(): AmendmentLedgerEntry = - amendmentLedgerEntry.getOrThrow("amendmentLedgerEntry") + fun asAmendment(): Amendment = amendment.getOrThrow("amendment") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) - decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) - expirationChangeLedgerEntry != null -> - visitor.visitExpirationChangeLedgerEntry(expirationChangeLedgerEntry) - creditBlockExpiryLedgerEntry != null -> - visitor.visitCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry) - voidLedgerEntry != null -> visitor.visitVoidLedgerEntry(voidLedgerEntry) - voidInitiatedLedgerEntry != null -> - visitor.visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry) - amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) + increment != null -> visitor.visitIncrement(increment) + decrement != null -> visitor.visitDecrement(decrement) + expirationChange != null -> visitor.visitExpirationChange(expirationChange) + creditBlockExpiry != null -> visitor.visitCreditBlockExpiry(creditBlockExpiry) + void_ != null -> visitor.visitVoid(void_) + voidInitiated != null -> visitor.visitVoidInitiated(voidInitiated) + amendment != null -> visitor.visitAmendment(amendment) else -> visitor.unknown(_json) } @@ -128,38 +113,32 @@ private constructor( accept( object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) { - incrementLedgerEntry.validate() + override fun visitIncrement(increment: Increment) { + increment.validate() } - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) { - decrementLedgerEntry.validate() + override fun visitDecrement(decrement: Decrement) { + decrement.validate() } - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) { - expirationChangeLedgerEntry.validate() + override fun visitExpirationChange(expirationChange: ExpirationChange) { + expirationChange.validate() } - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) { - creditBlockExpiryLedgerEntry.validate() + override fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) { + creditBlockExpiry.validate() } - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) { - voidLedgerEntry.validate() + override fun visitVoid(void_: Void) { + void_.validate() } - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) { - voidInitiatedLedgerEntry.validate() + override fun visitVoidInitiated(voidInitiated: VoidInitiated) { + voidInitiated.validate() } - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) { - amendmentLedgerEntry.validate() + override fun visitAmendment(amendment: Amendment) { + amendment.validate() } } ) @@ -183,29 +162,22 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - incrementLedgerEntry.validity() + override fun visitIncrement(increment: Increment) = increment.validity() - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - decrementLedgerEntry.validity() + override fun visitDecrement(decrement: Decrement) = decrement.validity() - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = expirationChangeLedgerEntry.validity() + override fun visitExpirationChange(expirationChange: ExpirationChange) = + expirationChange.validity() - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = creditBlockExpiryLedgerEntry.validity() + override fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) = + creditBlockExpiry.validity() - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - voidLedgerEntry.validity() + override fun visitVoid(void_: Void) = void_.validity() - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) = voidInitiatedLedgerEntry.validity() + override fun visitVoidInitiated(voidInitiated: VoidInitiated) = + voidInitiated.validity() - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - amendmentLedgerEntry.validity() + override fun visitAmendment(amendment: Amendment) = amendment.validity() override fun unknown(json: JsonValue?) = 0 } @@ -216,27 +188,26 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListByExternalIdResponse && incrementLedgerEntry == other.incrementLedgerEntry && decrementLedgerEntry == other.decrementLedgerEntry && expirationChangeLedgerEntry == other.expirationChangeLedgerEntry && creditBlockExpiryLedgerEntry == other.creditBlockExpiryLedgerEntry && voidLedgerEntry == other.voidLedgerEntry && voidInitiatedLedgerEntry == other.voidInitiatedLedgerEntry && amendmentLedgerEntry == other.amendmentLedgerEntry /* spotless:on */ + 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 */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementLedgerEntry, decrementLedgerEntry, expirationChangeLedgerEntry, creditBlockExpiryLedgerEntry, voidLedgerEntry, voidInitiatedLedgerEntry, amendmentLedgerEntry) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, creditBlockExpiry, void_, voidInitiated, amendment) /* spotless:on */ override fun toString(): String = when { - incrementLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{incrementLedgerEntry=$incrementLedgerEntry}" - decrementLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{decrementLedgerEntry=$decrementLedgerEntry}" - expirationChangeLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{expirationChangeLedgerEntry=$expirationChangeLedgerEntry}" - creditBlockExpiryLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{creditBlockExpiryLedgerEntry=$creditBlockExpiryLedgerEntry}" - voidLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{voidLedgerEntry=$voidLedgerEntry}" - voidInitiatedLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{voidInitiatedLedgerEntry=$voidInitiatedLedgerEntry}" - amendmentLedgerEntry != null -> - "CustomerCreditLedgerListByExternalIdResponse{amendmentLedgerEntry=$amendmentLedgerEntry}" + increment != null -> + "CustomerCreditLedgerListByExternalIdResponse{increment=$increment}" + decrement != null -> + "CustomerCreditLedgerListByExternalIdResponse{decrement=$decrement}" + expirationChange != null -> + "CustomerCreditLedgerListByExternalIdResponse{expirationChange=$expirationChange}" + creditBlockExpiry != null -> + "CustomerCreditLedgerListByExternalIdResponse{creditBlockExpiry=$creditBlockExpiry}" + void_ != null -> "CustomerCreditLedgerListByExternalIdResponse{void_=$void_}" + voidInitiated != null -> + "CustomerCreditLedgerListByExternalIdResponse{voidInitiated=$voidInitiated}" + amendment != null -> + "CustomerCreditLedgerListByExternalIdResponse{amendment=$amendment}" _json != null -> "CustomerCreditLedgerListByExternalIdResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid CustomerCreditLedgerListByExternalIdResponse") @@ -245,48 +216,31 @@ private constructor( companion object { @JvmStatic - fun ofIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse( - incrementLedgerEntry = incrementLedgerEntry - ) + fun ofIncrement(increment: Increment) = + CustomerCreditLedgerListByExternalIdResponse(increment = increment) @JvmStatic - fun ofDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse( - decrementLedgerEntry = decrementLedgerEntry - ) + fun ofDecrement(decrement: Decrement) = + CustomerCreditLedgerListByExternalIdResponse(decrement = decrement) @JvmStatic - fun ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = - CustomerCreditLedgerListByExternalIdResponse( - expirationChangeLedgerEntry = expirationChangeLedgerEntry - ) + fun ofExpirationChange(expirationChange: ExpirationChange) = + CustomerCreditLedgerListByExternalIdResponse(expirationChange = expirationChange) @JvmStatic - fun ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = - CustomerCreditLedgerListByExternalIdResponse( - creditBlockExpiryLedgerEntry = creditBlockExpiryLedgerEntry - ) + fun ofCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) = + CustomerCreditLedgerListByExternalIdResponse(creditBlockExpiry = creditBlockExpiry) @JvmStatic - fun ofVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse(voidLedgerEntry = voidLedgerEntry) + fun ofVoid(void_: Void) = CustomerCreditLedgerListByExternalIdResponse(void_ = void_) @JvmStatic - fun ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse( - voidInitiatedLedgerEntry = voidInitiatedLedgerEntry - ) + fun ofVoidInitiated(voidInitiated: VoidInitiated) = + CustomerCreditLedgerListByExternalIdResponse(voidInitiated = voidInitiated) @JvmStatic - fun ofAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - CustomerCreditLedgerListByExternalIdResponse( - amendmentLedgerEntry = amendmentLedgerEntry - ) + fun ofAmendment(amendment: Amendment) = + CustomerCreditLedgerListByExternalIdResponse(amendment = amendment) } /** @@ -295,23 +249,19 @@ private constructor( */ interface Visitor { - fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry): T + fun visitIncrement(increment: Increment): T - fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry): T + fun visitDecrement(decrement: Decrement): T - fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ): T + fun visitExpirationChange(expirationChange: ExpirationChange): T - fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ): T + fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry): T - fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry): T + fun visitVoid(void_: Void): T - fun visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry): T + fun visitVoidInitiated(voidInitiated: VoidInitiated): T - fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry): T + fun visitAmendment(amendment: Amendment): T /** * Maps an unknown variant of [CustomerCreditLedgerListByExternalIdResponse] to a value of @@ -344,61 +294,47 @@ private constructor( when (entryType) { "increment" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerListByExternalIdResponse( - incrementLedgerEntry = it, - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListByExternalIdResponse(increment = it, _json = json) } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } "decrement" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListByExternalIdResponse(decrement = it, _json = json) + } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) + } + "expiration_change" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { CustomerCreditLedgerListByExternalIdResponse( - decrementLedgerEntry = it, + expirationChange = it, _json = json, ) } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } - "expiration_change" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - CustomerCreditLedgerListByExternalIdResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) - } "credit_block_expiry" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - CustomerCreditLedgerListByExternalIdResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) - } - "void" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { CustomerCreditLedgerListByExternalIdResponse( - voidLedgerEntry = it, + creditBlockExpiry = it, _json = json, ) } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } + "void" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListByExternalIdResponse(void_ = it, _json = json) + } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) + } "void_initiated" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { CustomerCreditLedgerListByExternalIdResponse( - voidInitiatedLedgerEntry = it, + voidInitiated = it, _json = json, ) } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } "amendment" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerListByExternalIdResponse( - amendmentLedgerEntry = it, - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListByExternalIdResponse(amendment = it, _json = json) } ?: CustomerCreditLedgerListByExternalIdResponse(_json = json) } } @@ -418,19 +354,13 @@ private constructor( provider: SerializerProvider, ) { when { - value.incrementLedgerEntry != null -> - generator.writeObject(value.incrementLedgerEntry) - value.decrementLedgerEntry != null -> - generator.writeObject(value.decrementLedgerEntry) - value.expirationChangeLedgerEntry != null -> - generator.writeObject(value.expirationChangeLedgerEntry) - value.creditBlockExpiryLedgerEntry != null -> - generator.writeObject(value.creditBlockExpiryLedgerEntry) - value.voidLedgerEntry != null -> generator.writeObject(value.voidLedgerEntry) - value.voidInitiatedLedgerEntry != null -> - generator.writeObject(value.voidInitiatedLedgerEntry) - value.amendmentLedgerEntry != null -> - generator.writeObject(value.amendmentLedgerEntry) + value.increment != null -> generator.writeObject(value.increment) + value.decrement != null -> generator.writeObject(value.decrement) + value.expirationChange != null -> generator.writeObject(value.expirationChange) + value.creditBlockExpiry != null -> generator.writeObject(value.creditBlockExpiry) + value.void_ != null -> generator.writeObject(value.void_) + value.voidInitiated != null -> generator.writeObject(value.voidInitiated) + value.amendment != null -> generator.writeObject(value.amendment) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException( @@ -440,7 +370,7 @@ private constructor( } } - class IncrementLedgerEntry + class Increment private constructor( private val id: JsonField, private val amount: JsonField, @@ -451,7 +381,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -483,9 +413,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -567,10 +495,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("increment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -669,15 +602,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -720,7 +644,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [IncrementLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Increment]. * * The following fields are required: * ```java @@ -733,7 +657,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -742,7 +665,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [IncrementLedgerEntry]. */ + /** A builder for [Increment]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -754,28 +677,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("increment") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(incrementLedgerEntry: IncrementLedgerEntry) = apply { - id = incrementLedgerEntry.id - amount = incrementLedgerEntry.amount - createdAt = incrementLedgerEntry.createdAt - creditBlock = incrementLedgerEntry.creditBlock - currency = incrementLedgerEntry.currency - customer = incrementLedgerEntry.customer - description = incrementLedgerEntry.description - endingBalance = incrementLedgerEntry.endingBalance - entryStatus = incrementLedgerEntry.entryStatus - entryType = incrementLedgerEntry.entryType - ledgerSequenceNumber = incrementLedgerEntry.ledgerSequenceNumber - metadata = incrementLedgerEntry.metadata - startingBalance = incrementLedgerEntry.startingBalance - additionalProperties = incrementLedgerEntry.additionalProperties.toMutableMap() + internal fun from(increment: Increment) = apply { + id = increment.id + amount = increment.amount + createdAt = increment.createdAt + creditBlock = increment.creditBlock + currency = increment.currency + customer = increment.customer + description = increment.description + endingBalance = increment.endingBalance + entryStatus = increment.entryStatus + entryType = increment.entryType + ledgerSequenceNumber = increment.ledgerSequenceNumber + metadata = increment.metadata + startingBalance = increment.startingBalance + additionalProperties = increment.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -890,16 +813,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("increment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -965,7 +891,7 @@ private constructor( } /** - * Returns an immutable instance of [IncrementLedgerEntry]. + * Returns an immutable instance of [Increment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -980,7 +906,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -988,8 +913,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): IncrementLedgerEntry = - IncrementLedgerEntry( + fun build(): Increment = + Increment( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -999,7 +924,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -1009,7 +934,7 @@ private constructor( private var validated: Boolean = false - fun validate(): IncrementLedgerEntry = apply { + fun validate(): Increment = apply { if (validated) { return@apply } @@ -1023,7 +948,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("increment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -1055,7 +984,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("increment")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -1654,129 +1583,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -1891,7 +1697,7 @@ 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 && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Increment && 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 */ } /* spotless:off */ @@ -1901,10 +1707,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "IncrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "Increment{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class DecrementLedgerEntry + class Decrement private constructor( private val id: JsonField, private val amount: JsonField, @@ -1915,7 +1721,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -1950,9 +1756,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -2042,10 +1846,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -2162,15 +1971,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -2234,7 +2034,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DecrementLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Decrement]. * * The following fields are required: * ```java @@ -2247,7 +2047,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -2256,7 +2055,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DecrementLedgerEntry]. */ + /** A builder for [Decrement]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -2268,7 +2067,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("decrement") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null @@ -2278,24 +2077,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(decrementLedgerEntry: DecrementLedgerEntry) = apply { - id = decrementLedgerEntry.id - amount = decrementLedgerEntry.amount - createdAt = decrementLedgerEntry.createdAt - creditBlock = decrementLedgerEntry.creditBlock - currency = decrementLedgerEntry.currency - customer = decrementLedgerEntry.customer - description = decrementLedgerEntry.description - endingBalance = decrementLedgerEntry.endingBalance - entryStatus = decrementLedgerEntry.entryStatus - entryType = decrementLedgerEntry.entryType - ledgerSequenceNumber = decrementLedgerEntry.ledgerSequenceNumber - metadata = decrementLedgerEntry.metadata - startingBalance = decrementLedgerEntry.startingBalance - eventId = decrementLedgerEntry.eventId - invoiceId = decrementLedgerEntry.invoiceId - priceId = decrementLedgerEntry.priceId - additionalProperties = decrementLedgerEntry.additionalProperties.toMutableMap() + internal fun from(decrement: Decrement) = apply { + id = decrement.id + amount = decrement.amount + createdAt = decrement.createdAt + creditBlock = decrement.creditBlock + currency = decrement.currency + customer = decrement.customer + description = decrement.description + endingBalance = decrement.endingBalance + entryStatus = decrement.entryStatus + entryType = decrement.entryType + ledgerSequenceNumber = decrement.ledgerSequenceNumber + metadata = decrement.metadata + startingBalance = decrement.startingBalance + eventId = decrement.eventId + invoiceId = decrement.invoiceId + priceId = decrement.priceId + additionalProperties = decrement.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2410,16 +2209,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -2527,7 +2329,7 @@ private constructor( } /** - * Returns an immutable instance of [DecrementLedgerEntry]. + * Returns an immutable instance of [Decrement]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2542,7 +2344,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -2550,8 +2351,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DecrementLedgerEntry = - DecrementLedgerEntry( + fun build(): Decrement = + Decrement( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -2561,7 +2362,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -2574,7 +2375,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DecrementLedgerEntry = apply { + fun validate(): Decrement = apply { if (validated) { return@apply } @@ -2588,7 +2389,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("decrement")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -2623,7 +2428,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("decrement")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) + @@ -3225,171 +3030,48 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** + * 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 + ) { - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - companion object { + fun toBuilder() = Builder().from(this) - @JvmField val DECREMENT = of("decrement") + companion object { - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() } - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } + /** A builder for [Metadata]. */ + class Builder internal constructor() { - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DECREMENT -> Value.DECREMENT - else -> Value._UNKNOWN + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + additionalProperties = metadata.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * User specified key-value pairs for the resource. If not present, this defaults to an - * empty dictionary. Individual keys can be removed by setting the value to `null`, and the - * entire metadata mapping can be cleared by setting `metadata` to `null`. - */ - class Metadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @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 putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { @@ -3462,7 +3144,7 @@ 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 /* spotless:off */ other is Decrement && 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 */ } /* spotless:off */ @@ -3472,10 +3154,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DecrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" + "Decrement{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" } - class ExpirationChangeLedgerEntry + class ExpirationChange private constructor( private val id: JsonField, private val amount: JsonField, @@ -3486,7 +3168,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val newBlockExpiryDate: JsonField, @@ -3519,9 +3201,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -3607,10 +3287,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -3716,15 +3401,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -3777,8 +3453,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExpirationChangeLedgerEntry]. + * Returns a mutable builder for constructing an instance of [ExpirationChange]. * * The following fields are required: * ```java @@ -3791,7 +3466,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -3801,7 +3475,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExpirationChangeLedgerEntry]. */ + /** A builder for [ExpirationChange]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -3813,7 +3487,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("expiration_change") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var newBlockExpiryDate: JsonField? = null @@ -3821,23 +3495,22 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(expirationChangeLedgerEntry: ExpirationChangeLedgerEntry) = apply { - id = expirationChangeLedgerEntry.id - amount = expirationChangeLedgerEntry.amount - createdAt = expirationChangeLedgerEntry.createdAt - creditBlock = expirationChangeLedgerEntry.creditBlock - currency = expirationChangeLedgerEntry.currency - customer = expirationChangeLedgerEntry.customer - description = expirationChangeLedgerEntry.description - endingBalance = expirationChangeLedgerEntry.endingBalance - entryStatus = expirationChangeLedgerEntry.entryStatus - entryType = expirationChangeLedgerEntry.entryType - ledgerSequenceNumber = expirationChangeLedgerEntry.ledgerSequenceNumber - metadata = expirationChangeLedgerEntry.metadata - newBlockExpiryDate = expirationChangeLedgerEntry.newBlockExpiryDate - startingBalance = expirationChangeLedgerEntry.startingBalance - additionalProperties = - expirationChangeLedgerEntry.additionalProperties.toMutableMap() + internal fun from(expirationChange: ExpirationChange) = apply { + id = expirationChange.id + amount = expirationChange.amount + createdAt = expirationChange.createdAt + creditBlock = expirationChange.creditBlock + currency = expirationChange.currency + customer = expirationChange.customer + description = expirationChange.description + endingBalance = expirationChange.endingBalance + entryStatus = expirationChange.entryStatus + entryType = expirationChange.entryType + ledgerSequenceNumber = expirationChange.ledgerSequenceNumber + metadata = expirationChange.metadata + newBlockExpiryDate = expirationChange.newBlockExpiryDate + startingBalance = expirationChange.startingBalance + additionalProperties = expirationChange.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3952,16 +3625,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -4048,7 +3724,7 @@ private constructor( } /** - * Returns an immutable instance of [ExpirationChangeLedgerEntry]. + * Returns an immutable instance of [ExpirationChange]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4063,7 +3739,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -4072,8 +3747,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): ExpirationChangeLedgerEntry = - ExpirationChangeLedgerEntry( + fun build(): ExpirationChange = + ExpirationChange( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -4083,7 +3758,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("newBlockExpiryDate", newBlockExpiryDate), @@ -4094,7 +3769,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExpirationChangeLedgerEntry = apply { + fun validate(): ExpirationChange = apply { if (validated) { return@apply } @@ -4108,7 +3783,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("expiration_change")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -4141,7 +3820,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("expiration_change")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + @@ -4741,129 +4420,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -4978,7 +4534,7 @@ 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 /* spotless:off */ other is ExpirationChange && 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 */ } /* spotless:off */ @@ -4988,10 +4544,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExpirationChangeLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "ExpirationChange{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class CreditBlockExpiryLedgerEntry + class CreditBlockExpiry private constructor( private val id: JsonField, private val amount: JsonField, @@ -5002,7 +4558,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -5034,9 +4590,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -5118,10 +4672,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("credit_block_expiry") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -5220,15 +4779,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -5271,8 +4821,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CreditBlockExpiryLedgerEntry]. + * Returns a mutable builder for constructing an instance of [CreditBlockExpiry]. * * The following fields are required: * ```java @@ -5285,7 +4834,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -5294,7 +4842,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CreditBlockExpiryLedgerEntry]. */ + /** A builder for [CreditBlockExpiry]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -5306,29 +4854,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("credit_block_expiry") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry) = apply { - id = creditBlockExpiryLedgerEntry.id - amount = creditBlockExpiryLedgerEntry.amount - createdAt = creditBlockExpiryLedgerEntry.createdAt - creditBlock = creditBlockExpiryLedgerEntry.creditBlock - currency = creditBlockExpiryLedgerEntry.currency - customer = creditBlockExpiryLedgerEntry.customer - description = creditBlockExpiryLedgerEntry.description - endingBalance = creditBlockExpiryLedgerEntry.endingBalance - entryStatus = creditBlockExpiryLedgerEntry.entryStatus - entryType = creditBlockExpiryLedgerEntry.entryType - ledgerSequenceNumber = creditBlockExpiryLedgerEntry.ledgerSequenceNumber - metadata = creditBlockExpiryLedgerEntry.metadata - startingBalance = creditBlockExpiryLedgerEntry.startingBalance - additionalProperties = - creditBlockExpiryLedgerEntry.additionalProperties.toMutableMap() + internal fun from(creditBlockExpiry: CreditBlockExpiry) = apply { + id = creditBlockExpiry.id + amount = creditBlockExpiry.amount + createdAt = creditBlockExpiry.createdAt + creditBlock = creditBlockExpiry.creditBlock + currency = creditBlockExpiry.currency + customer = creditBlockExpiry.customer + description = creditBlockExpiry.description + endingBalance = creditBlockExpiry.endingBalance + entryStatus = creditBlockExpiry.entryStatus + entryType = creditBlockExpiry.entryType + ledgerSequenceNumber = creditBlockExpiry.ledgerSequenceNumber + metadata = creditBlockExpiry.metadata + startingBalance = creditBlockExpiry.startingBalance + additionalProperties = creditBlockExpiry.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -5443,16 +4990,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("credit_block_expiry") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -5518,7 +5068,7 @@ private constructor( } /** - * Returns an immutable instance of [CreditBlockExpiryLedgerEntry]. + * Returns an immutable instance of [CreditBlockExpiry]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -5533,7 +5083,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -5541,8 +5090,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CreditBlockExpiryLedgerEntry = - CreditBlockExpiryLedgerEntry( + fun build(): CreditBlockExpiry = + CreditBlockExpiry( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -5552,7 +5101,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -5562,7 +5111,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CreditBlockExpiryLedgerEntry = apply { + fun validate(): CreditBlockExpiry = apply { if (validated) { return@apply } @@ -5576,7 +5125,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("credit_block_expiry")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -5608,7 +5161,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("credit_block_expiry")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -6207,129 +5760,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 CREDIT_BLOCK_EXPIRY = of("credit_block_expiry") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - CREDIT_BLOCK_EXPIRY - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREDIT_BLOCK_EXPIRY, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CREDIT_BLOCK_EXPIRY -> Value.CREDIT_BLOCK_EXPIRY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREDIT_BLOCK_EXPIRY -> Known.CREDIT_BLOCK_EXPIRY - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -6444,7 +5874,7 @@ 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 /* spotless:off */ other is CreditBlockExpiry && 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 */ } /* spotless:off */ @@ -6454,10 +5884,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CreditBlockExpiryLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "CreditBlockExpiry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class VoidLedgerEntry + class Void private constructor( private val id: JsonField, private val amount: JsonField, @@ -6468,7 +5898,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -6502,9 +5932,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -6594,10 +6022,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("void") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -6708,15 +6141,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -6777,7 +6201,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [VoidLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Void]. * * The following fields are required: * ```java @@ -6790,7 +6214,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -6801,7 +6224,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VoidLedgerEntry]. */ + /** A builder for [Void]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -6813,7 +6236,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null @@ -6822,23 +6245,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(voidLedgerEntry: VoidLedgerEntry) = apply { - id = voidLedgerEntry.id - amount = voidLedgerEntry.amount - createdAt = voidLedgerEntry.createdAt - creditBlock = voidLedgerEntry.creditBlock - currency = voidLedgerEntry.currency - customer = voidLedgerEntry.customer - description = voidLedgerEntry.description - endingBalance = voidLedgerEntry.endingBalance - entryStatus = voidLedgerEntry.entryStatus - entryType = voidLedgerEntry.entryType - ledgerSequenceNumber = voidLedgerEntry.ledgerSequenceNumber - metadata = voidLedgerEntry.metadata - startingBalance = voidLedgerEntry.startingBalance - voidAmount = voidLedgerEntry.voidAmount - voidReason = voidLedgerEntry.voidReason - additionalProperties = voidLedgerEntry.additionalProperties.toMutableMap() + internal fun from(void_: Void) = apply { + id = void_.id + amount = void_.amount + createdAt = void_.createdAt + creditBlock = void_.creditBlock + currency = void_.currency + customer = void_.customer + description = void_.description + endingBalance = void_.endingBalance + entryStatus = void_.entryStatus + entryType = void_.entryType + ledgerSequenceNumber = void_.ledgerSequenceNumber + metadata = void_.metadata + startingBalance = void_.startingBalance + voidAmount = void_.voidAmount + voidReason = void_.voidReason + additionalProperties = void_.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -6953,16 +6376,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -7053,7 +6479,7 @@ private constructor( } /** - * Returns an immutable instance of [VoidLedgerEntry]. + * Returns an immutable instance of [Void]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7068,7 +6494,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -7078,8 +6503,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VoidLedgerEntry = - VoidLedgerEntry( + fun build(): Void = + Void( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -7089,7 +6514,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -7101,7 +6526,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VoidLedgerEntry = apply { + fun validate(): Void = apply { if (validated) { return@apply } @@ -7115,7 +6540,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -7149,7 +6578,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) + @@ -7694,131 +7123,8 @@ private constructor( fun known(): Known = when (this) { COMMITTED -> Known.COMMITTED - PENDING -> Known.PENDING - else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryStatus = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") + PENDING -> Known.PENDING + else -> throw OrbInvalidDataException("Unknown EntryStatus: $value") } /** @@ -7835,7 +7141,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EntryType = apply { + fun validate(): EntryStatus = apply { if (validated) { return@apply } @@ -7865,7 +7171,7 @@ private constructor( return true } - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ + return /* spotless:off */ other is EntryStatus && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() @@ -7987,7 +7293,7 @@ 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 /* spotless:off */ other is Void && 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 */ } /* spotless:off */ @@ -7997,10 +7303,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VoidLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "Void{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class VoidInitiatedLedgerEntry + class VoidInitiated private constructor( private val id: JsonField, private val amount: JsonField, @@ -8011,7 +7317,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val newBlockExpiryDate: JsonField, @@ -8046,9 +7352,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -8142,10 +7446,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("void_initiated") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -8263,15 +7572,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -8342,7 +7642,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [VoidInitiatedLedgerEntry]. + * Returns a mutable builder for constructing an instance of [VoidInitiated]. * * The following fields are required: * ```java @@ -8355,7 +7655,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -8367,7 +7666,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VoidInitiatedLedgerEntry]. */ + /** A builder for [VoidInitiated]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -8379,7 +7678,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void_initiated") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var newBlockExpiryDate: JsonField? = null @@ -8389,24 +7688,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = apply { - id = voidInitiatedLedgerEntry.id - amount = voidInitiatedLedgerEntry.amount - createdAt = voidInitiatedLedgerEntry.createdAt - creditBlock = voidInitiatedLedgerEntry.creditBlock - currency = voidInitiatedLedgerEntry.currency - customer = voidInitiatedLedgerEntry.customer - description = voidInitiatedLedgerEntry.description - endingBalance = voidInitiatedLedgerEntry.endingBalance - entryStatus = voidInitiatedLedgerEntry.entryStatus - entryType = voidInitiatedLedgerEntry.entryType - ledgerSequenceNumber = voidInitiatedLedgerEntry.ledgerSequenceNumber - metadata = voidInitiatedLedgerEntry.metadata - newBlockExpiryDate = voidInitiatedLedgerEntry.newBlockExpiryDate - startingBalance = voidInitiatedLedgerEntry.startingBalance - voidAmount = voidInitiatedLedgerEntry.voidAmount - voidReason = voidInitiatedLedgerEntry.voidReason - additionalProperties = voidInitiatedLedgerEntry.additionalProperties.toMutableMap() + internal fun from(voidInitiated: VoidInitiated) = apply { + id = voidInitiated.id + amount = voidInitiated.amount + createdAt = voidInitiated.createdAt + creditBlock = voidInitiated.creditBlock + currency = voidInitiated.currency + customer = voidInitiated.customer + description = voidInitiated.description + endingBalance = voidInitiated.endingBalance + entryStatus = voidInitiated.entryStatus + entryType = voidInitiated.entryType + ledgerSequenceNumber = voidInitiated.ledgerSequenceNumber + metadata = voidInitiated.metadata + newBlockExpiryDate = voidInitiated.newBlockExpiryDate + startingBalance = voidInitiated.startingBalance + voidAmount = voidInitiated.voidAmount + voidReason = voidInitiated.voidReason + additionalProperties = voidInitiated.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -8521,16 +7820,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void_initiated") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -8635,7 +7937,7 @@ private constructor( } /** - * Returns an immutable instance of [VoidInitiatedLedgerEntry]. + * Returns an immutable instance of [VoidInitiated]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -8650,7 +7952,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -8661,8 +7962,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VoidInitiatedLedgerEntry = - VoidInitiatedLedgerEntry( + fun build(): VoidInitiated = + VoidInitiated( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -8672,7 +7973,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("newBlockExpiryDate", newBlockExpiryDate), @@ -8685,7 +7986,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VoidInitiatedLedgerEntry = apply { + fun validate(): VoidInitiated = apply { if (validated) { return@apply } @@ -8699,7 +8000,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void_initiated")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -8734,7 +8039,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void_initiated")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + @@ -9336,129 +8641,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 VOID_INITIATED = of("void_initiated") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID_INITIATED - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID_INITIATED, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID_INITIATED -> Value.VOID_INITIATED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID_INITIATED -> Known.VOID_INITIATED - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -9573,7 +8755,7 @@ 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 /* spotless:off */ other is VoidInitiated && 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 */ } /* spotless:off */ @@ -9583,10 +8765,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VoidInitiatedLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "VoidInitiated{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class AmendmentLedgerEntry + class Amendment private constructor( private val id: JsonField, private val amount: JsonField, @@ -9597,7 +8779,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -9629,9 +8811,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -9713,10 +8893,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -9815,15 +9000,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -9866,7 +9042,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AmendmentLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Amendment]. * * The following fields are required: * ```java @@ -9879,7 +9055,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -9888,7 +9063,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmendmentLedgerEntry]. */ + /** A builder for [Amendment]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -9900,28 +9075,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("amendment") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amendmentLedgerEntry: AmendmentLedgerEntry) = apply { - id = amendmentLedgerEntry.id - amount = amendmentLedgerEntry.amount - createdAt = amendmentLedgerEntry.createdAt - creditBlock = amendmentLedgerEntry.creditBlock - currency = amendmentLedgerEntry.currency - customer = amendmentLedgerEntry.customer - description = amendmentLedgerEntry.description - endingBalance = amendmentLedgerEntry.endingBalance - entryStatus = amendmentLedgerEntry.entryStatus - entryType = amendmentLedgerEntry.entryType - ledgerSequenceNumber = amendmentLedgerEntry.ledgerSequenceNumber - metadata = amendmentLedgerEntry.metadata - startingBalance = amendmentLedgerEntry.startingBalance - additionalProperties = amendmentLedgerEntry.additionalProperties.toMutableMap() + internal fun from(amendment: Amendment) = apply { + id = amendment.id + amount = amendment.amount + createdAt = amendment.createdAt + creditBlock = amendment.creditBlock + currency = amendment.currency + customer = amendment.customer + description = amendment.description + endingBalance = amendment.endingBalance + entryStatus = amendment.entryStatus + entryType = amendment.entryType + ledgerSequenceNumber = amendment.ledgerSequenceNumber + metadata = amendment.metadata + startingBalance = amendment.startingBalance + additionalProperties = amendment.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -10036,16 +9211,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -10111,7 +9289,7 @@ private constructor( } /** - * Returns an immutable instance of [AmendmentLedgerEntry]. + * Returns an immutable instance of [Amendment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -10126,7 +9304,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -10134,8 +9311,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmendmentLedgerEntry = - AmendmentLedgerEntry( + fun build(): Amendment = + Amendment( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -10145,7 +9322,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -10155,7 +9332,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmendmentLedgerEntry = apply { + fun validate(): Amendment = apply { if (validated) { return@apply } @@ -10169,7 +9346,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("amendment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -10201,7 +9382,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("amendment")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -10800,129 +9981,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -11037,7 +10095,7 @@ 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 /* spotless:off */ other is Amendment && 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 */ } /* spotless:off */ @@ -11047,6 +10105,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmendmentLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "Amendment{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } } 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 b5b1fbb4..0d653fe2 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.credits.LedgerService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [LedgerService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: LedgerService, private val params: CustomerCreditLedgerListParams, private val response: CustomerCreditLedgerListPageResponse, -) { +) : Page { /** * Delegates to [CustomerCreditLedgerListPageResponse], but gracefully handles missing data. @@ -34,31 +34,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditLedgerListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.list(it) } + override fun nextPage(): CustomerCreditLedgerListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CustomerCreditLedgerListParams = params @@ -129,26 +120,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CustomerCreditLedgerListPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 31bb8765..b2659070 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.credits.LedgerServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [LedgerServiceAsync.list] */ class CustomerCreditLedgerListPageAsync private constructor( private val service: LedgerServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CustomerCreditLedgerListParams, private val response: CustomerCreditLedgerListPageResponse, -) { +) : PageAsync { /** * Delegates to [CustomerCreditLedgerListPageResponse], but gracefully handles missing data. @@ -35,33 +37,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditLedgerListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CustomerCreditLedgerListParams = params @@ -80,6 +73,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -91,6 +85,7 @@ private constructor( class Builder internal constructor() { private var service: LedgerServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CustomerCreditLedgerListParams? = null private var response: CustomerCreditLedgerListPageResponse? = null @@ -98,12 +93,17 @@ private constructor( internal fun from(customerCreditLedgerListPageAsync: CustomerCreditLedgerListPageAsync) = apply { service = customerCreditLedgerListPageAsync.service + streamHandlerExecutor = customerCreditLedgerListPageAsync.streamHandlerExecutor params = customerCreditLedgerListPageAsync.params response = customerCreditLedgerListPageAsync.response } fun service(service: LedgerServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CustomerCreditLedgerListParams) = apply { this.params = params } @@ -120,6 +120,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -129,50 +130,22 @@ private constructor( fun build(): CustomerCreditLedgerListPageAsync = CustomerCreditLedgerListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CustomerCreditLedgerListPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (CustomerCreditLedgerListResponse) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerCreditLedgerListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CustomerCreditLedgerListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CustomerCreditLedgerListPageAsync{service=$service, params=$params, response=$response}" + "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 645d99e3..92af44c8 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 @@ -138,72 +138,49 @@ private constructor( /** * Alias for calling [addData] with - * `CustomerCreditLedgerListResponse.ofIncrementLedgerEntry(incrementLedgerEntry)`. + * `CustomerCreditLedgerListResponse.ofIncrement(increment)`. */ - fun addData(incrementLedgerEntry: CustomerCreditLedgerListResponse.IncrementLedgerEntry) = - addData(CustomerCreditLedgerListResponse.ofIncrementLedgerEntry(incrementLedgerEntry)) + fun addData(increment: CustomerCreditLedgerListResponse.Increment) = + addData(CustomerCreditLedgerListResponse.ofIncrement(increment)) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListResponse.ofDecrementLedgerEntry(decrementLedgerEntry)`. + * `CustomerCreditLedgerListResponse.ofDecrement(decrement)`. */ - fun addData(decrementLedgerEntry: CustomerCreditLedgerListResponse.DecrementLedgerEntry) = - addData(CustomerCreditLedgerListResponse.ofDecrementLedgerEntry(decrementLedgerEntry)) + fun addData(decrement: CustomerCreditLedgerListResponse.Decrement) = + addData(CustomerCreditLedgerListResponse.ofDecrement(decrement)) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListResponse.ofExpirationChangeLedgerEntry(expirationChangeLedgerEntry)`. + * `CustomerCreditLedgerListResponse.ofExpirationChange(expirationChange)`. */ - fun addData( - expirationChangeLedgerEntry: - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry - ) = - addData( - CustomerCreditLedgerListResponse.ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry - ) - ) + fun addData(expirationChange: CustomerCreditLedgerListResponse.ExpirationChange) = + addData(CustomerCreditLedgerListResponse.ofExpirationChange(expirationChange)) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListResponse.ofCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry)`. + * `CustomerCreditLedgerListResponse.ofCreditBlockExpiry(creditBlockExpiry)`. */ - fun addData( - creditBlockExpiryLedgerEntry: - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry - ) = - addData( - CustomerCreditLedgerListResponse.ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry - ) - ) + fun addData(creditBlockExpiry: CustomerCreditLedgerListResponse.CreditBlockExpiry) = + addData(CustomerCreditLedgerListResponse.ofCreditBlockExpiry(creditBlockExpiry)) - /** - * Alias for calling [addData] with - * `CustomerCreditLedgerListResponse.ofVoidLedgerEntry(voidLedgerEntry)`. - */ - fun addData(voidLedgerEntry: CustomerCreditLedgerListResponse.VoidLedgerEntry) = - addData(CustomerCreditLedgerListResponse.ofVoidLedgerEntry(voidLedgerEntry)) + /** Alias for calling [addData] with `CustomerCreditLedgerListResponse.ofVoid(void_)`. */ + fun addData(void_: CustomerCreditLedgerListResponse.Void) = + addData(CustomerCreditLedgerListResponse.ofVoid(void_)) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListResponse.ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry)`. + * `CustomerCreditLedgerListResponse.ofVoidInitiated(voidInitiated)`. */ - fun addData( - voidInitiatedLedgerEntry: CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry - ) = - addData( - CustomerCreditLedgerListResponse.ofVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry - ) - ) + fun addData(voidInitiated: CustomerCreditLedgerListResponse.VoidInitiated) = + addData(CustomerCreditLedgerListResponse.ofVoidInitiated(voidInitiated)) /** * Alias for calling [addData] with - * `CustomerCreditLedgerListResponse.ofAmendmentLedgerEntry(amendmentLedgerEntry)`. + * `CustomerCreditLedgerListResponse.ofAmendment(amendment)`. */ - fun addData(amendmentLedgerEntry: CustomerCreditLedgerListResponse.AmendmentLedgerEntry) = - addData(CustomerCreditLedgerListResponse.ofAmendmentLedgerEntry(amendmentLedgerEntry)) + fun addData(amendment: CustomerCreditLedgerListResponse.Amendment) = + addData(CustomerCreditLedgerListResponse.ofAmendment(amendment)) fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) 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 9d9efa69..61a6b3d1 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 @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException @@ -95,7 +94,7 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCreditLedgerListParams private constructor( - private val customerId: String, + private val customerId: String?, private val createdAtGt: OffsetDateTime?, private val createdAtGte: OffsetDateTime?, private val createdAtLt: OffsetDateTime?, @@ -110,7 +109,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) fun createdAtGt(): Optional = Optional.ofNullable(createdAtGt) @@ -146,14 +145,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerCreditLedgerListParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerCreditLedgerListParams]. - * - * The following fields are required: - * ```java - * .customerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -192,7 +188,10 @@ private constructor( additionalQueryParams = customerCreditLedgerListParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) fun createdAtGt(createdAtGt: OffsetDateTime?) = apply { this.createdAtGt = createdAtGt } @@ -364,17 +363,10 @@ private constructor( * Returns an immutable instance of [CustomerCreditLedgerListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerCreditLedgerListParams = CustomerCreditLedgerListParams( - checkRequired("customerId", customerId), + customerId, createdAtGt, createdAtGte, createdAtLt, @@ -392,7 +384,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 4edf63c6..429b0a1b 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 @@ -38,84 +38,69 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = CustomerCreditLedgerListResponse.Serializer::class) class CustomerCreditLedgerListResponse private constructor( - private val incrementLedgerEntry: IncrementLedgerEntry? = null, - private val decrementLedgerEntry: DecrementLedgerEntry? = null, - private val expirationChangeLedgerEntry: ExpirationChangeLedgerEntry? = null, - private val creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry? = null, - private val voidLedgerEntry: VoidLedgerEntry? = null, - private val voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry? = null, - private val amendmentLedgerEntry: AmendmentLedgerEntry? = null, + private val increment: Increment? = null, + private val decrement: Decrement? = null, + private val expirationChange: ExpirationChange? = null, + private val creditBlockExpiry: CreditBlockExpiry? = null, + private val void_: Void? = null, + private val voidInitiated: VoidInitiated? = null, + private val amendment: Amendment? = null, private val _json: JsonValue? = null, ) { - fun incrementLedgerEntry(): Optional = - Optional.ofNullable(incrementLedgerEntry) + fun increment(): Optional = Optional.ofNullable(increment) - fun decrementLedgerEntry(): Optional = - Optional.ofNullable(decrementLedgerEntry) + fun decrement(): Optional = Optional.ofNullable(decrement) - fun expirationChangeLedgerEntry(): Optional = - Optional.ofNullable(expirationChangeLedgerEntry) + fun expirationChange(): Optional = Optional.ofNullable(expirationChange) - fun creditBlockExpiryLedgerEntry(): Optional = - Optional.ofNullable(creditBlockExpiryLedgerEntry) + fun creditBlockExpiry(): Optional = Optional.ofNullable(creditBlockExpiry) - fun voidLedgerEntry(): Optional = Optional.ofNullable(voidLedgerEntry) + fun void_(): Optional = Optional.ofNullable(void_) - fun voidInitiatedLedgerEntry(): Optional = - Optional.ofNullable(voidInitiatedLedgerEntry) + fun voidInitiated(): Optional = Optional.ofNullable(voidInitiated) - fun amendmentLedgerEntry(): Optional = - Optional.ofNullable(amendmentLedgerEntry) + fun amendment(): Optional = Optional.ofNullable(amendment) - fun isIncrementLedgerEntry(): Boolean = incrementLedgerEntry != null + fun isIncrement(): Boolean = increment != null - fun isDecrementLedgerEntry(): Boolean = decrementLedgerEntry != null + fun isDecrement(): Boolean = decrement != null - fun isExpirationChangeLedgerEntry(): Boolean = expirationChangeLedgerEntry != null + fun isExpirationChange(): Boolean = expirationChange != null - fun isCreditBlockExpiryLedgerEntry(): Boolean = creditBlockExpiryLedgerEntry != null + fun isCreditBlockExpiry(): Boolean = creditBlockExpiry != null - fun isVoidLedgerEntry(): Boolean = voidLedgerEntry != null + fun isVoid(): Boolean = void_ != null - fun isVoidInitiatedLedgerEntry(): Boolean = voidInitiatedLedgerEntry != null + fun isVoidInitiated(): Boolean = voidInitiated != null - fun isAmendmentLedgerEntry(): Boolean = amendmentLedgerEntry != null + fun isAmendment(): Boolean = amendment != null - fun asIncrementLedgerEntry(): IncrementLedgerEntry = - incrementLedgerEntry.getOrThrow("incrementLedgerEntry") + fun asIncrement(): Increment = increment.getOrThrow("increment") - fun asDecrementLedgerEntry(): DecrementLedgerEntry = - decrementLedgerEntry.getOrThrow("decrementLedgerEntry") + fun asDecrement(): Decrement = decrement.getOrThrow("decrement") - fun asExpirationChangeLedgerEntry(): ExpirationChangeLedgerEntry = - expirationChangeLedgerEntry.getOrThrow("expirationChangeLedgerEntry") + fun asExpirationChange(): ExpirationChange = expirationChange.getOrThrow("expirationChange") - fun asCreditBlockExpiryLedgerEntry(): CreditBlockExpiryLedgerEntry = - creditBlockExpiryLedgerEntry.getOrThrow("creditBlockExpiryLedgerEntry") + fun asCreditBlockExpiry(): CreditBlockExpiry = creditBlockExpiry.getOrThrow("creditBlockExpiry") - fun asVoidLedgerEntry(): VoidLedgerEntry = voidLedgerEntry.getOrThrow("voidLedgerEntry") + fun asVoid(): Void = void_.getOrThrow("void_") - fun asVoidInitiatedLedgerEntry(): VoidInitiatedLedgerEntry = - voidInitiatedLedgerEntry.getOrThrow("voidInitiatedLedgerEntry") + fun asVoidInitiated(): VoidInitiated = voidInitiated.getOrThrow("voidInitiated") - fun asAmendmentLedgerEntry(): AmendmentLedgerEntry = - amendmentLedgerEntry.getOrThrow("amendmentLedgerEntry") + fun asAmendment(): Amendment = amendment.getOrThrow("amendment") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - incrementLedgerEntry != null -> visitor.visitIncrementLedgerEntry(incrementLedgerEntry) - decrementLedgerEntry != null -> visitor.visitDecrementLedgerEntry(decrementLedgerEntry) - expirationChangeLedgerEntry != null -> - visitor.visitExpirationChangeLedgerEntry(expirationChangeLedgerEntry) - creditBlockExpiryLedgerEntry != null -> - visitor.visitCreditBlockExpiryLedgerEntry(creditBlockExpiryLedgerEntry) - voidLedgerEntry != null -> visitor.visitVoidLedgerEntry(voidLedgerEntry) - voidInitiatedLedgerEntry != null -> - visitor.visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry) - amendmentLedgerEntry != null -> visitor.visitAmendmentLedgerEntry(amendmentLedgerEntry) + increment != null -> visitor.visitIncrement(increment) + decrement != null -> visitor.visitDecrement(decrement) + expirationChange != null -> visitor.visitExpirationChange(expirationChange) + creditBlockExpiry != null -> visitor.visitCreditBlockExpiry(creditBlockExpiry) + void_ != null -> visitor.visitVoid(void_) + voidInitiated != null -> visitor.visitVoidInitiated(voidInitiated) + amendment != null -> visitor.visitAmendment(amendment) else -> visitor.unknown(_json) } @@ -128,38 +113,32 @@ private constructor( accept( object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) { - incrementLedgerEntry.validate() + override fun visitIncrement(increment: Increment) { + increment.validate() } - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) { - decrementLedgerEntry.validate() + override fun visitDecrement(decrement: Decrement) { + decrement.validate() } - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) { - expirationChangeLedgerEntry.validate() + override fun visitExpirationChange(expirationChange: ExpirationChange) { + expirationChange.validate() } - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) { - creditBlockExpiryLedgerEntry.validate() + override fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) { + creditBlockExpiry.validate() } - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) { - voidLedgerEntry.validate() + override fun visitVoid(void_: Void) { + void_.validate() } - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) { - voidInitiatedLedgerEntry.validate() + override fun visitVoidInitiated(voidInitiated: VoidInitiated) { + voidInitiated.validate() } - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) { - amendmentLedgerEntry.validate() + override fun visitAmendment(amendment: Amendment) { + amendment.validate() } } ) @@ -183,29 +162,22 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - incrementLedgerEntry.validity() + override fun visitIncrement(increment: Increment) = increment.validity() - override fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - decrementLedgerEntry.validity() + override fun visitDecrement(decrement: Decrement) = decrement.validity() - override fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = expirationChangeLedgerEntry.validity() + override fun visitExpirationChange(expirationChange: ExpirationChange) = + expirationChange.validity() - override fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = creditBlockExpiryLedgerEntry.validity() + override fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) = + creditBlockExpiry.validity() - override fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - voidLedgerEntry.validity() + override fun visitVoid(void_: Void) = void_.validity() - override fun visitVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry - ) = voidInitiatedLedgerEntry.validity() + override fun visitVoidInitiated(voidInitiated: VoidInitiated) = + voidInitiated.validity() - override fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - amendmentLedgerEntry.validity() + override fun visitAmendment(amendment: Amendment) = amendment.validity() override fun unknown(json: JsonValue?) = 0 } @@ -216,27 +188,23 @@ private constructor( return true } - return /* spotless:off */ other is CustomerCreditLedgerListResponse && incrementLedgerEntry == other.incrementLedgerEntry && decrementLedgerEntry == other.decrementLedgerEntry && expirationChangeLedgerEntry == other.expirationChangeLedgerEntry && creditBlockExpiryLedgerEntry == other.creditBlockExpiryLedgerEntry && voidLedgerEntry == other.voidLedgerEntry && voidInitiatedLedgerEntry == other.voidInitiatedLedgerEntry && amendmentLedgerEntry == other.amendmentLedgerEntry /* spotless:on */ + 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 */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(incrementLedgerEntry, decrementLedgerEntry, expirationChangeLedgerEntry, creditBlockExpiryLedgerEntry, voidLedgerEntry, voidInitiatedLedgerEntry, amendmentLedgerEntry) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(increment, decrement, expirationChange, creditBlockExpiry, void_, voidInitiated, amendment) /* spotless:on */ override fun toString(): String = when { - incrementLedgerEntry != null -> - "CustomerCreditLedgerListResponse{incrementLedgerEntry=$incrementLedgerEntry}" - decrementLedgerEntry != null -> - "CustomerCreditLedgerListResponse{decrementLedgerEntry=$decrementLedgerEntry}" - expirationChangeLedgerEntry != null -> - "CustomerCreditLedgerListResponse{expirationChangeLedgerEntry=$expirationChangeLedgerEntry}" - creditBlockExpiryLedgerEntry != null -> - "CustomerCreditLedgerListResponse{creditBlockExpiryLedgerEntry=$creditBlockExpiryLedgerEntry}" - voidLedgerEntry != null -> - "CustomerCreditLedgerListResponse{voidLedgerEntry=$voidLedgerEntry}" - voidInitiatedLedgerEntry != null -> - "CustomerCreditLedgerListResponse{voidInitiatedLedgerEntry=$voidInitiatedLedgerEntry}" - amendmentLedgerEntry != null -> - "CustomerCreditLedgerListResponse{amendmentLedgerEntry=$amendmentLedgerEntry}" + increment != null -> "CustomerCreditLedgerListResponse{increment=$increment}" + decrement != null -> "CustomerCreditLedgerListResponse{decrement=$decrement}" + expirationChange != null -> + "CustomerCreditLedgerListResponse{expirationChange=$expirationChange}" + creditBlockExpiry != null -> + "CustomerCreditLedgerListResponse{creditBlockExpiry=$creditBlockExpiry}" + void_ != null -> "CustomerCreditLedgerListResponse{void_=$void_}" + voidInitiated != null -> + "CustomerCreditLedgerListResponse{voidInitiated=$voidInitiated}" + amendment != null -> "CustomerCreditLedgerListResponse{amendment=$amendment}" _json != null -> "CustomerCreditLedgerListResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid CustomerCreditLedgerListResponse") } @@ -244,40 +212,30 @@ private constructor( companion object { @JvmStatic - fun ofIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry) = - CustomerCreditLedgerListResponse(incrementLedgerEntry = incrementLedgerEntry) + fun ofIncrement(increment: Increment) = + CustomerCreditLedgerListResponse(increment = increment) @JvmStatic - fun ofDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry) = - CustomerCreditLedgerListResponse(decrementLedgerEntry = decrementLedgerEntry) + fun ofDecrement(decrement: Decrement) = + CustomerCreditLedgerListResponse(decrement = decrement) @JvmStatic - fun ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ) = - CustomerCreditLedgerListResponse( - expirationChangeLedgerEntry = expirationChangeLedgerEntry - ) + fun ofExpirationChange(expirationChange: ExpirationChange) = + CustomerCreditLedgerListResponse(expirationChange = expirationChange) @JvmStatic - fun ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ) = - CustomerCreditLedgerListResponse( - creditBlockExpiryLedgerEntry = creditBlockExpiryLedgerEntry - ) + fun ofCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry) = + CustomerCreditLedgerListResponse(creditBlockExpiry = creditBlockExpiry) - @JvmStatic - fun ofVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry) = - CustomerCreditLedgerListResponse(voidLedgerEntry = voidLedgerEntry) + @JvmStatic fun ofVoid(void_: Void) = CustomerCreditLedgerListResponse(void_ = void_) @JvmStatic - fun ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = - CustomerCreditLedgerListResponse(voidInitiatedLedgerEntry = voidInitiatedLedgerEntry) + fun ofVoidInitiated(voidInitiated: VoidInitiated) = + CustomerCreditLedgerListResponse(voidInitiated = voidInitiated) @JvmStatic - fun ofAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry) = - CustomerCreditLedgerListResponse(amendmentLedgerEntry = amendmentLedgerEntry) + fun ofAmendment(amendment: Amendment) = + CustomerCreditLedgerListResponse(amendment = amendment) } /** @@ -286,23 +244,19 @@ private constructor( */ interface Visitor { - fun visitIncrementLedgerEntry(incrementLedgerEntry: IncrementLedgerEntry): T + fun visitIncrement(increment: Increment): T - fun visitDecrementLedgerEntry(decrementLedgerEntry: DecrementLedgerEntry): T + fun visitDecrement(decrement: Decrement): T - fun visitExpirationChangeLedgerEntry( - expirationChangeLedgerEntry: ExpirationChangeLedgerEntry - ): T + fun visitExpirationChange(expirationChange: ExpirationChange): T - fun visitCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry - ): T + fun visitCreditBlockExpiry(creditBlockExpiry: CreditBlockExpiry): T - fun visitVoidLedgerEntry(voidLedgerEntry: VoidLedgerEntry): T + fun visitVoid(void_: Void): T - fun visitVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry): T + fun visitVoidInitiated(voidInitiated: VoidInitiated): T - fun visitAmendmentLedgerEntry(amendmentLedgerEntry: AmendmentLedgerEntry): T + fun visitAmendment(amendment: Amendment): T /** * Maps an unknown variant of [CustomerCreditLedgerListResponse] to a value of type [T]. @@ -330,49 +284,38 @@ private constructor( when (entryType) { "increment" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerListResponse(incrementLedgerEntry = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(increment = it, _json = json) } ?: CustomerCreditLedgerListResponse(_json = json) } "decrement" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerListResponse(decrementLedgerEntry = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(decrement = it, _json = json) } ?: CustomerCreditLedgerListResponse(_json = json) } "expiration_change" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - CustomerCreditLedgerListResponse( - expirationChangeLedgerEntry = it, - _json = json, - ) - } ?: CustomerCreditLedgerListResponse(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(expirationChange = it, _json = json) + } ?: CustomerCreditLedgerListResponse(_json = json) } "credit_block_expiry" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { - CustomerCreditLedgerListResponse( - creditBlockExpiryLedgerEntry = it, - _json = json, - ) - } ?: CustomerCreditLedgerListResponse(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(creditBlockExpiry = it, _json = json) + } ?: CustomerCreditLedgerListResponse(_json = json) } "void" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerListResponse(voidLedgerEntry = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(void_ = it, _json = json) } ?: CustomerCreditLedgerListResponse(_json = json) } "void_initiated" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerListResponse( - voidInitiatedLedgerEntry = it, - _json = json, - ) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(voidInitiated = it, _json = json) } ?: CustomerCreditLedgerListResponse(_json = json) } "amendment" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - CustomerCreditLedgerListResponse(amendmentLedgerEntry = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + CustomerCreditLedgerListResponse(amendment = it, _json = json) } ?: CustomerCreditLedgerListResponse(_json = json) } } @@ -390,26 +333,20 @@ private constructor( provider: SerializerProvider, ) { when { - value.incrementLedgerEntry != null -> - generator.writeObject(value.incrementLedgerEntry) - value.decrementLedgerEntry != null -> - generator.writeObject(value.decrementLedgerEntry) - value.expirationChangeLedgerEntry != null -> - generator.writeObject(value.expirationChangeLedgerEntry) - value.creditBlockExpiryLedgerEntry != null -> - generator.writeObject(value.creditBlockExpiryLedgerEntry) - value.voidLedgerEntry != null -> generator.writeObject(value.voidLedgerEntry) - value.voidInitiatedLedgerEntry != null -> - generator.writeObject(value.voidInitiatedLedgerEntry) - value.amendmentLedgerEntry != null -> - generator.writeObject(value.amendmentLedgerEntry) + value.increment != null -> generator.writeObject(value.increment) + value.decrement != null -> generator.writeObject(value.decrement) + value.expirationChange != null -> generator.writeObject(value.expirationChange) + value.creditBlockExpiry != null -> generator.writeObject(value.creditBlockExpiry) + value.void_ != null -> generator.writeObject(value.void_) + value.voidInitiated != null -> generator.writeObject(value.voidInitiated) + value.amendment != null -> generator.writeObject(value.amendment) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid CustomerCreditLedgerListResponse") } } } - class IncrementLedgerEntry + class Increment private constructor( private val id: JsonField, private val amount: JsonField, @@ -420,7 +357,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -452,9 +389,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -536,10 +471,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("increment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -638,15 +578,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -689,7 +620,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [IncrementLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Increment]. * * The following fields are required: * ```java @@ -702,7 +633,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -711,7 +641,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [IncrementLedgerEntry]. */ + /** A builder for [Increment]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -723,28 +653,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("increment") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(incrementLedgerEntry: IncrementLedgerEntry) = apply { - id = incrementLedgerEntry.id - amount = incrementLedgerEntry.amount - createdAt = incrementLedgerEntry.createdAt - creditBlock = incrementLedgerEntry.creditBlock - currency = incrementLedgerEntry.currency - customer = incrementLedgerEntry.customer - description = incrementLedgerEntry.description - endingBalance = incrementLedgerEntry.endingBalance - entryStatus = incrementLedgerEntry.entryStatus - entryType = incrementLedgerEntry.entryType - ledgerSequenceNumber = incrementLedgerEntry.ledgerSequenceNumber - metadata = incrementLedgerEntry.metadata - startingBalance = incrementLedgerEntry.startingBalance - additionalProperties = incrementLedgerEntry.additionalProperties.toMutableMap() + internal fun from(increment: Increment) = apply { + id = increment.id + amount = increment.amount + createdAt = increment.createdAt + creditBlock = increment.creditBlock + currency = increment.currency + customer = increment.customer + description = increment.description + endingBalance = increment.endingBalance + entryStatus = increment.entryStatus + entryType = increment.entryType + ledgerSequenceNumber = increment.ledgerSequenceNumber + metadata = increment.metadata + startingBalance = increment.startingBalance + additionalProperties = increment.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -859,16 +789,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("increment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -934,7 +867,7 @@ private constructor( } /** - * Returns an immutable instance of [IncrementLedgerEntry]. + * Returns an immutable instance of [Increment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -949,7 +882,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -957,8 +889,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): IncrementLedgerEntry = - IncrementLedgerEntry( + fun build(): Increment = + Increment( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -968,7 +900,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -978,7 +910,7 @@ private constructor( private var validated: Boolean = false - fun validate(): IncrementLedgerEntry = apply { + fun validate(): Increment = apply { if (validated) { return@apply } @@ -992,7 +924,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("increment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -1024,7 +960,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("increment")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -1623,129 +1559,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - INCREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -1860,7 +1673,7 @@ 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 && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Increment && 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 */ } /* spotless:off */ @@ -1870,10 +1683,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "IncrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "Increment{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class DecrementLedgerEntry + class Decrement private constructor( private val id: JsonField, private val amount: JsonField, @@ -1884,7 +1697,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -1919,9 +1732,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -2011,10 +1822,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -2131,15 +1947,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -2203,7 +2010,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DecrementLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Decrement]. * * The following fields are required: * ```java @@ -2216,7 +2023,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -2225,7 +2031,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [DecrementLedgerEntry]. */ + /** A builder for [Decrement]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -2237,7 +2043,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("decrement") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null @@ -2247,24 +2053,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(decrementLedgerEntry: DecrementLedgerEntry) = apply { - id = decrementLedgerEntry.id - amount = decrementLedgerEntry.amount - createdAt = decrementLedgerEntry.createdAt - creditBlock = decrementLedgerEntry.creditBlock - currency = decrementLedgerEntry.currency - customer = decrementLedgerEntry.customer - description = decrementLedgerEntry.description - endingBalance = decrementLedgerEntry.endingBalance - entryStatus = decrementLedgerEntry.entryStatus - entryType = decrementLedgerEntry.entryType - ledgerSequenceNumber = decrementLedgerEntry.ledgerSequenceNumber - metadata = decrementLedgerEntry.metadata - startingBalance = decrementLedgerEntry.startingBalance - eventId = decrementLedgerEntry.eventId - invoiceId = decrementLedgerEntry.invoiceId - priceId = decrementLedgerEntry.priceId - additionalProperties = decrementLedgerEntry.additionalProperties.toMutableMap() + internal fun from(decrement: Decrement) = apply { + id = decrement.id + amount = decrement.amount + createdAt = decrement.createdAt + creditBlock = decrement.creditBlock + currency = decrement.currency + customer = decrement.customer + description = decrement.description + endingBalance = decrement.endingBalance + entryStatus = decrement.entryStatus + entryType = decrement.entryType + ledgerSequenceNumber = decrement.ledgerSequenceNumber + metadata = decrement.metadata + startingBalance = decrement.startingBalance + eventId = decrement.eventId + invoiceId = decrement.invoiceId + priceId = decrement.priceId + additionalProperties = decrement.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2379,16 +2185,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("decrement") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -2496,7 +2305,7 @@ private constructor( } /** - * Returns an immutable instance of [DecrementLedgerEntry]. + * Returns an immutable instance of [Decrement]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2511,7 +2320,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -2519,8 +2327,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): DecrementLedgerEntry = - DecrementLedgerEntry( + fun build(): Decrement = + Decrement( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -2530,7 +2338,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -2543,7 +2351,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DecrementLedgerEntry = apply { + fun validate(): Decrement = apply { if (validated) { return@apply } @@ -2557,7 +2365,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("decrement")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -2592,7 +2404,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("decrement")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) + @@ -3194,129 +3006,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 DECREMENT = of("decrement") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - DECREMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DECREMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - 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) { - DECREMENT -> Known.DECREMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -3431,7 +3120,7 @@ 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 /* spotless:off */ other is Decrement && 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 */ } /* spotless:off */ @@ -3441,10 +3130,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DecrementLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" + "Decrement{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, eventId=$eventId, invoiceId=$invoiceId, priceId=$priceId, additionalProperties=$additionalProperties}" } - class ExpirationChangeLedgerEntry + class ExpirationChange private constructor( private val id: JsonField, private val amount: JsonField, @@ -3455,7 +3144,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val newBlockExpiryDate: JsonField, @@ -3488,9 +3177,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -3576,10 +3263,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -3685,15 +3377,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -3746,8 +3429,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ExpirationChangeLedgerEntry]. + * Returns a mutable builder for constructing an instance of [ExpirationChange]. * * The following fields are required: * ```java @@ -3760,7 +3442,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -3770,7 +3451,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ExpirationChangeLedgerEntry]. */ + /** A builder for [ExpirationChange]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -3782,7 +3463,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("expiration_change") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var newBlockExpiryDate: JsonField? = null @@ -3790,23 +3471,22 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(expirationChangeLedgerEntry: ExpirationChangeLedgerEntry) = apply { - id = expirationChangeLedgerEntry.id - amount = expirationChangeLedgerEntry.amount - createdAt = expirationChangeLedgerEntry.createdAt - creditBlock = expirationChangeLedgerEntry.creditBlock - currency = expirationChangeLedgerEntry.currency - customer = expirationChangeLedgerEntry.customer - description = expirationChangeLedgerEntry.description - endingBalance = expirationChangeLedgerEntry.endingBalance - entryStatus = expirationChangeLedgerEntry.entryStatus - entryType = expirationChangeLedgerEntry.entryType - ledgerSequenceNumber = expirationChangeLedgerEntry.ledgerSequenceNumber - metadata = expirationChangeLedgerEntry.metadata - newBlockExpiryDate = expirationChangeLedgerEntry.newBlockExpiryDate - startingBalance = expirationChangeLedgerEntry.startingBalance - additionalProperties = - expirationChangeLedgerEntry.additionalProperties.toMutableMap() + internal fun from(expirationChange: ExpirationChange) = apply { + id = expirationChange.id + amount = expirationChange.amount + createdAt = expirationChange.createdAt + creditBlock = expirationChange.creditBlock + currency = expirationChange.currency + customer = expirationChange.customer + description = expirationChange.description + endingBalance = expirationChange.endingBalance + entryStatus = expirationChange.entryStatus + entryType = expirationChange.entryType + ledgerSequenceNumber = expirationChange.ledgerSequenceNumber + metadata = expirationChange.metadata + newBlockExpiryDate = expirationChange.newBlockExpiryDate + startingBalance = expirationChange.startingBalance + additionalProperties = expirationChange.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3921,16 +3601,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("expiration_change") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -4017,7 +3700,7 @@ private constructor( } /** - * Returns an immutable instance of [ExpirationChangeLedgerEntry]. + * Returns an immutable instance of [ExpirationChange]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4032,7 +3715,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -4041,8 +3723,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): ExpirationChangeLedgerEntry = - ExpirationChangeLedgerEntry( + fun build(): ExpirationChange = + ExpirationChange( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -4052,7 +3734,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("newBlockExpiryDate", newBlockExpiryDate), @@ -4063,7 +3745,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ExpirationChangeLedgerEntry = apply { + fun validate(): ExpirationChange = apply { if (validated) { return@apply } @@ -4077,7 +3759,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("expiration_change")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -4110,7 +3796,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("expiration_change")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + @@ -4710,129 +4396,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 EXPIRATION_CHANGE = of("expiration_change") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - EXPIRATION_CHANGE - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EXPIRATION_CHANGE, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EXPIRATION_CHANGE -> Value.EXPIRATION_CHANGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - EXPIRATION_CHANGE -> Known.EXPIRATION_CHANGE - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -4947,7 +4510,7 @@ 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 /* spotless:off */ other is ExpirationChange && 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 */ } /* spotless:off */ @@ -4957,10 +4520,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExpirationChangeLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "ExpirationChange{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class CreditBlockExpiryLedgerEntry + class CreditBlockExpiry private constructor( private val id: JsonField, private val amount: JsonField, @@ -4971,7 +4534,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -5003,9 +4566,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -5087,10 +4648,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("credit_block_expiry") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -5189,15 +4755,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -5240,8 +4797,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CreditBlockExpiryLedgerEntry]. + * Returns a mutable builder for constructing an instance of [CreditBlockExpiry]. * * The following fields are required: * ```java @@ -5254,7 +4810,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -5263,7 +4818,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CreditBlockExpiryLedgerEntry]. */ + /** A builder for [CreditBlockExpiry]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -5275,29 +4830,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("credit_block_expiry") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(creditBlockExpiryLedgerEntry: CreditBlockExpiryLedgerEntry) = apply { - id = creditBlockExpiryLedgerEntry.id - amount = creditBlockExpiryLedgerEntry.amount - createdAt = creditBlockExpiryLedgerEntry.createdAt - creditBlock = creditBlockExpiryLedgerEntry.creditBlock - currency = creditBlockExpiryLedgerEntry.currency - customer = creditBlockExpiryLedgerEntry.customer - description = creditBlockExpiryLedgerEntry.description - endingBalance = creditBlockExpiryLedgerEntry.endingBalance - entryStatus = creditBlockExpiryLedgerEntry.entryStatus - entryType = creditBlockExpiryLedgerEntry.entryType - ledgerSequenceNumber = creditBlockExpiryLedgerEntry.ledgerSequenceNumber - metadata = creditBlockExpiryLedgerEntry.metadata - startingBalance = creditBlockExpiryLedgerEntry.startingBalance - additionalProperties = - creditBlockExpiryLedgerEntry.additionalProperties.toMutableMap() + internal fun from(creditBlockExpiry: CreditBlockExpiry) = apply { + id = creditBlockExpiry.id + amount = creditBlockExpiry.amount + createdAt = creditBlockExpiry.createdAt + creditBlock = creditBlockExpiry.creditBlock + currency = creditBlockExpiry.currency + customer = creditBlockExpiry.customer + description = creditBlockExpiry.description + endingBalance = creditBlockExpiry.endingBalance + entryStatus = creditBlockExpiry.entryStatus + entryType = creditBlockExpiry.entryType + ledgerSequenceNumber = creditBlockExpiry.ledgerSequenceNumber + metadata = creditBlockExpiry.metadata + startingBalance = creditBlockExpiry.startingBalance + additionalProperties = creditBlockExpiry.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -5412,16 +4966,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("credit_block_expiry") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -5487,7 +5044,7 @@ private constructor( } /** - * Returns an immutable instance of [CreditBlockExpiryLedgerEntry]. + * Returns an immutable instance of [CreditBlockExpiry]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -5502,7 +5059,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -5510,8 +5066,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CreditBlockExpiryLedgerEntry = - CreditBlockExpiryLedgerEntry( + fun build(): CreditBlockExpiry = + CreditBlockExpiry( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -5521,7 +5077,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -5531,7 +5087,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CreditBlockExpiryLedgerEntry = apply { + fun validate(): CreditBlockExpiry = apply { if (validated) { return@apply } @@ -5545,7 +5101,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("credit_block_expiry")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -5577,7 +5137,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("credit_block_expiry")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -6176,129 +5736,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 CREDIT_BLOCK_EXPIRY = of("credit_block_expiry") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - CREDIT_BLOCK_EXPIRY - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREDIT_BLOCK_EXPIRY, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CREDIT_BLOCK_EXPIRY -> Value.CREDIT_BLOCK_EXPIRY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREDIT_BLOCK_EXPIRY -> Known.CREDIT_BLOCK_EXPIRY - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -6413,7 +5850,7 @@ 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 /* spotless:off */ other is CreditBlockExpiry && 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 */ } /* spotless:off */ @@ -6423,10 +5860,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CreditBlockExpiryLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "CreditBlockExpiry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } - class VoidLedgerEntry + class Void private constructor( private val id: JsonField, private val amount: JsonField, @@ -6437,7 +5874,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -6471,9 +5908,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -6563,10 +5998,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("void") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -6678,16 +6118,7 @@ private constructor( fun _entryStatus(): JsonField = entryStatus /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - - /** - * Returns the raw JSON value of [ledgerSequenceNumber]. + * Returns the raw JSON value of [ledgerSequenceNumber]. * * Unlike [ledgerSequenceNumber], this method doesn't throw if the JSON field has an * unexpected type. @@ -6746,7 +6177,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [VoidLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Void]. * * The following fields are required: * ```java @@ -6759,7 +6190,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -6770,7 +6200,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VoidLedgerEntry]. */ + /** A builder for [Void]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -6782,7 +6212,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null @@ -6791,23 +6221,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(voidLedgerEntry: VoidLedgerEntry) = apply { - id = voidLedgerEntry.id - amount = voidLedgerEntry.amount - createdAt = voidLedgerEntry.createdAt - creditBlock = voidLedgerEntry.creditBlock - currency = voidLedgerEntry.currency - customer = voidLedgerEntry.customer - description = voidLedgerEntry.description - endingBalance = voidLedgerEntry.endingBalance - entryStatus = voidLedgerEntry.entryStatus - entryType = voidLedgerEntry.entryType - ledgerSequenceNumber = voidLedgerEntry.ledgerSequenceNumber - metadata = voidLedgerEntry.metadata - startingBalance = voidLedgerEntry.startingBalance - voidAmount = voidLedgerEntry.voidAmount - voidReason = voidLedgerEntry.voidReason - additionalProperties = voidLedgerEntry.additionalProperties.toMutableMap() + internal fun from(void_: Void) = apply { + id = void_.id + amount = void_.amount + createdAt = void_.createdAt + creditBlock = void_.creditBlock + currency = void_.currency + customer = void_.customer + description = void_.description + endingBalance = void_.endingBalance + entryStatus = void_.entryStatus + entryType = void_.entryType + ledgerSequenceNumber = void_.ledgerSequenceNumber + metadata = void_.metadata + startingBalance = void_.startingBalance + voidAmount = void_.voidAmount + voidReason = void_.voidReason + additionalProperties = void_.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -6922,16 +6352,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -7022,7 +6455,7 @@ private constructor( } /** - * Returns an immutable instance of [VoidLedgerEntry]. + * Returns an immutable instance of [Void]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7037,7 +6470,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -7047,8 +6479,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VoidLedgerEntry = - VoidLedgerEntry( + fun build(): Void = + Void( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -7058,7 +6490,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -7070,7 +6502,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VoidLedgerEntry = apply { + fun validate(): Void = apply { if (validated) { return@apply } @@ -7084,7 +6516,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -7118,7 +6554,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) + @@ -7719,129 +7155,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 VOID = of("void") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID -> Value.VOID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID -> Known.VOID - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -7956,7 +7269,7 @@ 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 /* spotless:off */ other is Void && 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 */ } /* spotless:off */ @@ -7966,10 +7279,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VoidLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "Void{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class VoidInitiatedLedgerEntry + class VoidInitiated private constructor( private val id: JsonField, private val amount: JsonField, @@ -7980,7 +7293,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val newBlockExpiryDate: JsonField, @@ -8015,9 +7328,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -8111,10 +7422,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("void_initiated") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -8232,15 +7548,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -8311,7 +7618,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [VoidInitiatedLedgerEntry]. + * Returns a mutable builder for constructing an instance of [VoidInitiated]. * * The following fields are required: * ```java @@ -8324,7 +7631,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -8336,7 +7642,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [VoidInitiatedLedgerEntry]. */ + /** A builder for [VoidInitiated]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -8348,7 +7654,7 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("void_initiated") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var newBlockExpiryDate: JsonField? = null @@ -8358,24 +7664,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(voidInitiatedLedgerEntry: VoidInitiatedLedgerEntry) = apply { - id = voidInitiatedLedgerEntry.id - amount = voidInitiatedLedgerEntry.amount - createdAt = voidInitiatedLedgerEntry.createdAt - creditBlock = voidInitiatedLedgerEntry.creditBlock - currency = voidInitiatedLedgerEntry.currency - customer = voidInitiatedLedgerEntry.customer - description = voidInitiatedLedgerEntry.description - endingBalance = voidInitiatedLedgerEntry.endingBalance - entryStatus = voidInitiatedLedgerEntry.entryStatus - entryType = voidInitiatedLedgerEntry.entryType - ledgerSequenceNumber = voidInitiatedLedgerEntry.ledgerSequenceNumber - metadata = voidInitiatedLedgerEntry.metadata - newBlockExpiryDate = voidInitiatedLedgerEntry.newBlockExpiryDate - startingBalance = voidInitiatedLedgerEntry.startingBalance - voidAmount = voidInitiatedLedgerEntry.voidAmount - voidReason = voidInitiatedLedgerEntry.voidReason - additionalProperties = voidInitiatedLedgerEntry.additionalProperties.toMutableMap() + internal fun from(voidInitiated: VoidInitiated) = apply { + id = voidInitiated.id + amount = voidInitiated.amount + createdAt = voidInitiated.createdAt + creditBlock = voidInitiated.creditBlock + currency = voidInitiated.currency + customer = voidInitiated.customer + description = voidInitiated.description + endingBalance = voidInitiated.endingBalance + entryStatus = voidInitiated.entryStatus + entryType = voidInitiated.entryType + ledgerSequenceNumber = voidInitiated.ledgerSequenceNumber + metadata = voidInitiated.metadata + newBlockExpiryDate = voidInitiated.newBlockExpiryDate + startingBalance = voidInitiated.startingBalance + voidAmount = voidInitiated.voidAmount + voidReason = voidInitiated.voidReason + additionalProperties = voidInitiated.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -8490,16 +7796,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("void_initiated") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -8604,7 +7913,7 @@ private constructor( } /** - * Returns an immutable instance of [VoidInitiatedLedgerEntry]. + * Returns an immutable instance of [VoidInitiated]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -8619,7 +7928,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .newBlockExpiryDate() @@ -8630,8 +7938,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): VoidInitiatedLedgerEntry = - VoidInitiatedLedgerEntry( + fun build(): VoidInitiated = + VoidInitiated( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -8641,7 +7949,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("newBlockExpiryDate", newBlockExpiryDate), @@ -8654,7 +7962,7 @@ private constructor( private var validated: Boolean = false - fun validate(): VoidInitiatedLedgerEntry = apply { + fun validate(): VoidInitiated = apply { if (validated) { return@apply } @@ -8668,7 +7976,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("void_initiated")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() newBlockExpiryDate() @@ -8703,7 +8015,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("void_initiated")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (newBlockExpiryDate.asKnown().isPresent) 1 else 0) + @@ -9305,129 +8617,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 VOID_INITIATED = of("void_initiated") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - VOID_INITIATED - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - VOID_INITIATED, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - VOID_INITIATED -> Value.VOID_INITIATED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - VOID_INITIATED -> Known.VOID_INITIATED - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -9542,7 +8731,7 @@ 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 /* spotless:off */ other is VoidInitiated && 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 */ } /* spotless:off */ @@ -9552,10 +8741,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "VoidInitiatedLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" + "VoidInitiated{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, newBlockExpiryDate=$newBlockExpiryDate, startingBalance=$startingBalance, voidAmount=$voidAmount, voidReason=$voidReason, additionalProperties=$additionalProperties}" } - class AmendmentLedgerEntry + class Amendment private constructor( private val id: JsonField, private val amount: JsonField, @@ -9566,7 +8755,7 @@ private constructor( private val description: JsonField, private val endingBalance: JsonField, private val entryStatus: JsonField, - private val entryType: JsonField, + private val entryType: JsonValue, private val ledgerSequenceNumber: JsonField, private val metadata: JsonField, private val startingBalance: JsonField, @@ -9598,9 +8787,7 @@ private constructor( @JsonProperty("entry_status") @ExcludeMissing entryStatus: JsonField = JsonMissing.of(), - @JsonProperty("entry_type") - @ExcludeMissing - entryType: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") @ExcludeMissing entryType: JsonValue = JsonMissing.of(), @JsonProperty("ledger_sequence_number") @ExcludeMissing ledgerSequenceNumber: JsonField = JsonMissing.of(), @@ -9682,10 +8869,15 @@ private constructor( fun entryStatus(): EntryStatus = entryStatus.getRequired("entry_status") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + * Expected to always return the following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun entryType(): EntryType = entryType.getRequired("entry_type") + @JsonProperty("entry_type") @ExcludeMissing fun _entryType(): JsonValue = entryType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -9784,15 +8976,6 @@ private constructor( @ExcludeMissing fun _entryStatus(): JsonField = entryStatus - /** - * Returns the raw JSON value of [entryType]. - * - * Unlike [entryType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("entry_type") - @ExcludeMissing - fun _entryType(): JsonField = entryType - /** * Returns the raw JSON value of [ledgerSequenceNumber]. * @@ -9835,7 +9018,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AmendmentLedgerEntry]. + * Returns a mutable builder for constructing an instance of [Amendment]. * * The following fields are required: * ```java @@ -9848,7 +9031,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -9857,7 +9039,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmendmentLedgerEntry]. */ + /** A builder for [Amendment]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -9869,28 +9051,28 @@ private constructor( private var description: JsonField? = null private var endingBalance: JsonField? = null private var entryStatus: JsonField? = null - private var entryType: JsonField? = null + private var entryType: JsonValue = JsonValue.from("amendment") private var ledgerSequenceNumber: JsonField? = null private var metadata: JsonField? = null private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amendmentLedgerEntry: AmendmentLedgerEntry) = apply { - id = amendmentLedgerEntry.id - amount = amendmentLedgerEntry.amount - createdAt = amendmentLedgerEntry.createdAt - creditBlock = amendmentLedgerEntry.creditBlock - currency = amendmentLedgerEntry.currency - customer = amendmentLedgerEntry.customer - description = amendmentLedgerEntry.description - endingBalance = amendmentLedgerEntry.endingBalance - entryStatus = amendmentLedgerEntry.entryStatus - entryType = amendmentLedgerEntry.entryType - ledgerSequenceNumber = amendmentLedgerEntry.ledgerSequenceNumber - metadata = amendmentLedgerEntry.metadata - startingBalance = amendmentLedgerEntry.startingBalance - additionalProperties = amendmentLedgerEntry.additionalProperties.toMutableMap() + internal fun from(amendment: Amendment) = apply { + id = amendment.id + amount = amendment.amount + createdAt = amendment.createdAt + creditBlock = amendment.creditBlock + currency = amendment.currency + customer = amendment.customer + description = amendment.description + endingBalance = amendment.endingBalance + entryStatus = amendment.entryStatus + entryType = amendment.entryType + ledgerSequenceNumber = amendment.ledgerSequenceNumber + metadata = amendment.metadata + startingBalance = amendment.startingBalance + additionalProperties = amendment.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -10005,16 +9187,19 @@ private constructor( this.entryStatus = entryStatus } - fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) - /** - * Sets [Builder.entryType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.entryType] with a well-typed [EntryType] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amendment") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun entryType(entryType: JsonField) = apply { this.entryType = entryType } + fun entryType(entryType: JsonValue) = apply { this.entryType = entryType } fun ledgerSequenceNumber(ledgerSequenceNumber: Long) = ledgerSequenceNumber(JsonField.of(ledgerSequenceNumber)) @@ -10080,7 +9265,7 @@ private constructor( } /** - * Returns an immutable instance of [AmendmentLedgerEntry]. + * Returns an immutable instance of [Amendment]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -10095,7 +9280,6 @@ private constructor( * .description() * .endingBalance() * .entryStatus() - * .entryType() * .ledgerSequenceNumber() * .metadata() * .startingBalance() @@ -10103,8 +9287,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmendmentLedgerEntry = - AmendmentLedgerEntry( + fun build(): Amendment = + Amendment( checkRequired("id", id), checkRequired("amount", amount), checkRequired("createdAt", createdAt), @@ -10114,7 +9298,7 @@ private constructor( checkRequired("description", description), checkRequired("endingBalance", endingBalance), checkRequired("entryStatus", entryStatus), - checkRequired("entryType", entryType), + entryType, checkRequired("ledgerSequenceNumber", ledgerSequenceNumber), checkRequired("metadata", metadata), checkRequired("startingBalance", startingBalance), @@ -10124,7 +9308,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmendmentLedgerEntry = apply { + fun validate(): Amendment = apply { if (validated) { return@apply } @@ -10138,7 +9322,11 @@ private constructor( description() endingBalance() entryStatus().validate() - entryType().validate() + _entryType().let { + if (it != JsonValue.from("amendment")) { + throw OrbInvalidDataException("'entryType' is invalid, received $it") + } + } ledgerSequenceNumber() metadata().validate() startingBalance() @@ -10170,7 +9358,7 @@ private constructor( (if (description.asKnown().isPresent) 1 else 0) + (if (endingBalance.asKnown().isPresent) 1 else 0) + (entryStatus.asKnown().getOrNull()?.validity() ?: 0) + - (entryType.asKnown().getOrNull()?.validity() ?: 0) + + entryType.let { if (it == JsonValue.from("amendment")) 1 else 0 } + (if (ledgerSequenceNumber.asKnown().isPresent) 1 else 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + (if (startingBalance.asKnown().isPresent) 1 else 0) @@ -10769,129 +9957,6 @@ private constructor( override fun toString() = value.toString() } - class EntryType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then 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 AMENDMENT = of("amendment") - - @JvmStatic fun of(value: String) = EntryType(JsonField.of(value)) - } - - /** An enum containing [EntryType]'s known values. */ - enum class Known { - AMENDMENT - } - - /** - * An enum containing [EntryType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EntryType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMENDMENT, - /** - * An enum member indicating that [EntryType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMENDMENT -> Value.AMENDMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMENDMENT -> Known.AMENDMENT - else -> throw OrbInvalidDataException("Unknown EntryType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): EntryType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EntryType && value == other.value /* spotless:on */ - } - - 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 @@ -11006,7 +10071,7 @@ 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 /* spotless:off */ other is Amendment && 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 */ } /* spotless:off */ @@ -11016,6 +10081,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmendmentLedgerEntry{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" + "Amendment{id=$id, amount=$amount, createdAt=$createdAt, creditBlock=$creditBlock, currency=$currency, customer=$customer, description=$description, endingBalance=$endingBalance, entryStatus=$entryStatus, entryType=$entryType, ledgerSequenceNumber=$ledgerSequenceNumber, metadata=$metadata, startingBalance=$startingBalance, additionalProperties=$additionalProperties}" } } 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 c63f6aa6..7d2f7364 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.CreditService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [CreditService.listByExternalId] */ @@ -16,7 +16,7 @@ private constructor( private val service: CreditService, private val params: CustomerCreditListByExternalIdParams, private val response: CustomerCreditListByExternalIdPageResponse, -) { +) : Page { /** * Delegates to [CustomerCreditListByExternalIdPageResponse], but gracefully handles missing @@ -36,31 +36,23 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditListByExternalIdParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.listByExternalId(it) } + override fun nextPage(): CustomerCreditListByExternalIdPage = + service.listByExternalId(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CustomerCreditListByExternalIdParams = params @@ -133,26 +125,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CustomerCreditListByExternalIdPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 a15138b2..0fe94b19 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [CreditServiceAsync.listByExternalId] */ class CustomerCreditListByExternalIdPageAsync private constructor( private val service: CreditServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CustomerCreditListByExternalIdParams, private val response: CustomerCreditListByExternalIdPageResponse, -) { +) : PageAsync { /** * Delegates to [CustomerCreditListByExternalIdPageResponse], but gracefully handles missing @@ -37,33 +39,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditListByExternalIdParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.listByExternalId(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.listByExternalId(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CustomerCreditListByExternalIdParams = params @@ -82,6 +75,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -93,6 +87,7 @@ private constructor( class Builder internal constructor() { private var service: CreditServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CustomerCreditListByExternalIdParams? = null private var response: CustomerCreditListByExternalIdPageResponse? = null @@ -101,12 +96,17 @@ private constructor( customerCreditListByExternalIdPageAsync: CustomerCreditListByExternalIdPageAsync ) = apply { service = customerCreditListByExternalIdPageAsync.service + streamHandlerExecutor = customerCreditListByExternalIdPageAsync.streamHandlerExecutor params = customerCreditListByExternalIdPageAsync.params response = customerCreditListByExternalIdPageAsync.response } fun service(service: CreditServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CustomerCreditListByExternalIdParams) = apply { this.params = params } @@ -123,6 +123,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -132,52 +133,22 @@ private constructor( fun build(): CustomerCreditListByExternalIdPageAsync = CustomerCreditListByExternalIdPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CustomerCreditListByExternalIdPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (CustomerCreditListByExternalIdResponse) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList( - executor: Executor - ): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerCreditListByExternalIdPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CustomerCreditListByExternalIdPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CustomerCreditListByExternalIdPageAsync{service=$service, params=$params, response=$response}" + "CustomerCreditListByExternalIdPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 a5ab67ad..144e5b75 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects @@ -21,7 +20,7 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCreditListByExternalIdParams private constructor( - private val externalCustomerId: String, + private val externalCustomerId: String?, private val currency: String?, private val cursor: String?, private val includeAllBlocks: Boolean?, @@ -30,7 +29,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun externalCustomerId(): String = externalCustomerId + fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) /** The ledger currency or custom pricing unit to use. */ fun currency(): Optional = Optional.ofNullable(currency) @@ -57,14 +56,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerCreditListByExternalIdParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerCreditListByExternalIdParams]. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -94,10 +90,16 @@ private constructor( customerCreditListByExternalIdParams.additionalQueryParams.toBuilder() } - fun externalCustomerId(externalCustomerId: String) = apply { + fun externalCustomerId(externalCustomerId: String?) = apply { this.externalCustomerId = externalCustomerId } + /** + * Alias for calling [Builder.externalCustomerId] with `externalCustomerId.orElse(null)`. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.getOrNull()) + /** The ledger currency or custom pricing unit to use. */ fun currency(currency: String?) = apply { this.currency = currency } @@ -248,17 +250,10 @@ private constructor( * Returns an immutable instance of [CustomerCreditListByExternalIdParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerCreditListByExternalIdParams = CustomerCreditListByExternalIdParams( - checkRequired("externalCustomerId", externalCustomerId), + externalCustomerId, currency, cursor, includeAllBlocks, @@ -270,7 +265,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalCustomerId + 0 -> externalCustomerId ?: "" else -> "" } 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 df86a0a8..d24c2af5 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.CreditService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [CreditService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: CreditService, private val params: CustomerCreditListParams, private val response: CustomerCreditListPageResponse, -) { +) : Page { /** * Delegates to [CustomerCreditListPageResponse], but gracefully handles missing data. @@ -34,31 +34,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.list(it) } + override fun nextPage(): CustomerCreditListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CustomerCreditListParams = params @@ -127,26 +118,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CustomerCreditListPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 03272689..ff22d0f2 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.CreditServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [CreditServiceAsync.list] */ class CustomerCreditListPageAsync private constructor( private val service: CreditServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CustomerCreditListParams, private val response: CustomerCreditListPageResponse, -) { +) : PageAsync { /** * Delegates to [CustomerCreditListPageResponse], but gracefully handles missing data. @@ -35,33 +37,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CustomerCreditListParams = params @@ -79,6 +72,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -90,18 +84,24 @@ private constructor( class Builder internal constructor() { private var service: CreditServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CustomerCreditListParams? = null private var response: CustomerCreditListPageResponse? = null @JvmSynthetic internal fun from(customerCreditListPageAsync: CustomerCreditListPageAsync) = apply { service = customerCreditListPageAsync.service + streamHandlerExecutor = customerCreditListPageAsync.streamHandlerExecutor params = customerCreditListPageAsync.params response = customerCreditListPageAsync.response } fun service(service: CreditServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CustomerCreditListParams) = apply { this.params = params } @@ -116,6 +116,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -125,50 +126,22 @@ private constructor( fun build(): CustomerCreditListPageAsync = CustomerCreditListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CustomerCreditListPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (CustomerCreditListResponse) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerCreditListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CustomerCreditListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CustomerCreditListPageAsync{service=$service, params=$params, response=$response}" + "CustomerCreditListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 210e227b..54fbcf43 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects @@ -21,7 +20,7 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCreditListParams private constructor( - private val customerId: String, + private val customerId: String?, private val currency: String?, private val cursor: String?, private val includeAllBlocks: Boolean?, @@ -30,7 +29,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) /** The ledger currency or custom pricing unit to use. */ fun currency(): Optional = Optional.ofNullable(currency) @@ -57,14 +56,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CustomerCreditListParams]. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - */ + @JvmStatic fun none(): CustomerCreditListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CustomerCreditListParams]. */ @JvmStatic fun builder() = Builder() } @@ -90,7 +84,10 @@ private constructor( additionalQueryParams = customerCreditListParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) /** The ledger currency or custom pricing unit to use. */ fun currency(currency: String?) = apply { this.currency = currency } @@ -242,17 +239,10 @@ private constructor( * Returns an immutable instance of [CustomerCreditListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerCreditListParams = CustomerCreditListParams( - checkRequired("customerId", customerId), + customerId, currency, cursor, includeAllBlocks, @@ -264,7 +254,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 ace42fa8..5e1a8708 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 @@ -32,13 +32,13 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCreditTopUpCreateByExternalIdParams private constructor( - private val externalCustomerId: String, + private val externalCustomerId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun externalCustomerId(): String = externalCustomerId + fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) /** * The amount to increment when the threshold is reached. @@ -181,7 +181,6 @@ private constructor( * * The following fields are required: * ```java - * .externalCustomerId() * .amount() * .currency() * .invoiceSettings() @@ -212,10 +211,16 @@ private constructor( customerCreditTopUpCreateByExternalIdParams.additionalQueryParams.toBuilder() } - fun externalCustomerId(externalCustomerId: String) = apply { + fun externalCustomerId(externalCustomerId: String?) = apply { this.externalCustomerId = externalCustomerId } + /** + * Alias for calling [Builder.externalCustomerId] with `externalCustomerId.orElse(null)`. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.getOrNull()) + /** * Sets the entire request body. * @@ -491,7 +496,6 @@ private constructor( * * The following fields are required: * ```java - * .externalCustomerId() * .amount() * .currency() * .invoiceSettings() @@ -503,7 +507,7 @@ private constructor( */ fun build(): CustomerCreditTopUpCreateByExternalIdParams = CustomerCreditTopUpCreateByExternalIdParams( - checkRequired("externalCustomerId", externalCustomerId), + externalCustomerId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -514,7 +518,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalCustomerId + 0 -> externalCustomerId ?: "" else -> "" } 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 a564f867..a813d176 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 @@ -32,13 +32,13 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerCreditTopUpCreateParams private constructor( - private val customerId: String, + private val customerId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) /** * The amount to increment when the threshold is reached. @@ -181,7 +181,6 @@ private constructor( * * The following fields are required: * ```java - * .customerId() * .amount() * .currency() * .invoiceSettings() @@ -210,7 +209,10 @@ private constructor( customerCreditTopUpCreateParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) /** * Sets the entire request body. @@ -487,7 +489,6 @@ private constructor( * * The following fields are required: * ```java - * .customerId() * .amount() * .currency() * .invoiceSettings() @@ -499,7 +500,7 @@ private constructor( */ fun build(): CustomerCreditTopUpCreateParams = CustomerCreditTopUpCreateParams( - checkRequired("customerId", customerId), + customerId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -510,7 +511,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 3f7c71c8..308b299e 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 @@ -10,6 +10,7 @@ import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This deactivates the top-up and voids any invoices associated with pending credit blocks @@ -18,7 +19,7 @@ import java.util.Optional class CustomerCreditTopUpDeleteByExternalIdParams private constructor( private val externalCustomerId: String, - private val topUpId: String, + private val topUpId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -26,7 +27,7 @@ private constructor( fun externalCustomerId(): String = externalCustomerId - fun topUpId(): String = topUpId + fun topUpId(): Optional = Optional.ofNullable(topUpId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -45,7 +46,6 @@ private constructor( * The following fields are required: * ```java * .externalCustomerId() - * .topUpId() * ``` */ @JvmStatic fun builder() = Builder() @@ -78,7 +78,10 @@ private constructor( this.externalCustomerId = externalCustomerId } - fun topUpId(topUpId: String) = apply { this.topUpId = topUpId } + fun topUpId(topUpId: String?) = apply { this.topUpId = topUpId } + + /** Alias for calling [Builder.topUpId] with `topUpId.orElse(null)`. */ + fun topUpId(topUpId: Optional) = topUpId(topUpId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -208,7 +211,6 @@ private constructor( * The following fields are required: * ```java * .externalCustomerId() - * .topUpId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -216,7 +218,7 @@ private constructor( fun build(): CustomerCreditTopUpDeleteByExternalIdParams = CustomerCreditTopUpDeleteByExternalIdParams( checkRequired("externalCustomerId", externalCustomerId), - checkRequired("topUpId", topUpId), + topUpId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -229,7 +231,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { 0 -> externalCustomerId - 1 -> topUpId + 1 -> topUpId ?: "" else -> "" } 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 8ae900f6..e6206cab 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 @@ -10,6 +10,7 @@ import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This deactivates the top-up and voids any invoices associated with pending credit blocks @@ -18,7 +19,7 @@ import java.util.Optional class CustomerCreditTopUpDeleteParams private constructor( private val customerId: String, - private val topUpId: String, + private val topUpId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -26,7 +27,7 @@ private constructor( fun customerId(): String = customerId - fun topUpId(): String = topUpId + fun topUpId(): Optional = Optional.ofNullable(topUpId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -45,7 +46,6 @@ private constructor( * The following fields are required: * ```java * .customerId() - * .topUpId() * ``` */ @JvmStatic fun builder() = Builder() @@ -74,7 +74,10 @@ private constructor( fun customerId(customerId: String) = apply { this.customerId = customerId } - fun topUpId(topUpId: String) = apply { this.topUpId = topUpId } + fun topUpId(topUpId: String?) = apply { this.topUpId = topUpId } + + /** Alias for calling [Builder.topUpId] with `topUpId.orElse(null)`. */ + fun topUpId(topUpId: Optional) = topUpId(topUpId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -204,7 +207,6 @@ private constructor( * The following fields are required: * ```java * .customerId() - * .topUpId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -212,7 +214,7 @@ private constructor( fun build(): CustomerCreditTopUpDeleteParams = CustomerCreditTopUpDeleteParams( checkRequired("customerId", customerId), - checkRequired("topUpId", topUpId), + topUpId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -225,7 +227,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { 0 -> customerId - 1 -> topUpId + 1 -> topUpId ?: "" else -> "" } 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 7e1662ea..e04da8ac 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [TopUpService.listByExternalId] */ @@ -16,7 +16,7 @@ private constructor( private val service: TopUpService, private val params: CustomerCreditTopUpListByExternalIdParams, private val response: CustomerCreditTopUpListByExternalIdPageResponse, -) { +) : Page { /** * Delegates to [CustomerCreditTopUpListByExternalIdPageResponse], but gracefully handles @@ -36,31 +36,23 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditTopUpListByExternalIdParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.listByExternalId(it) } + override fun nextPage(): CustomerCreditTopUpListByExternalIdPage = + service.listByExternalId(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CustomerCreditTopUpListByExternalIdParams = params @@ -136,26 +128,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CustomerCreditTopUpListByExternalIdPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 7ea10578..1dab7a90 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [TopUpServiceAsync.listByExternalId] */ class CustomerCreditTopUpListByExternalIdPageAsync private constructor( private val service: TopUpServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CustomerCreditTopUpListByExternalIdParams, private val response: CustomerCreditTopUpListByExternalIdPageResponse, -) { +) : PageAsync { /** * Delegates to [CustomerCreditTopUpListByExternalIdPageResponse], but gracefully handles @@ -37,33 +39,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditTopUpListByExternalIdParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.listByExternalId(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.listByExternalId(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CustomerCreditTopUpListByExternalIdParams = params @@ -82,6 +75,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -93,6 +87,7 @@ private constructor( class Builder internal constructor() { private var service: TopUpServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CustomerCreditTopUpListByExternalIdParams? = null private var response: CustomerCreditTopUpListByExternalIdPageResponse? = null @@ -102,12 +97,18 @@ private constructor( CustomerCreditTopUpListByExternalIdPageAsync ) = apply { service = customerCreditTopUpListByExternalIdPageAsync.service + streamHandlerExecutor = + customerCreditTopUpListByExternalIdPageAsync.streamHandlerExecutor params = customerCreditTopUpListByExternalIdPageAsync.params response = customerCreditTopUpListByExternalIdPageAsync.response } fun service(service: TopUpServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CustomerCreditTopUpListByExternalIdParams) = apply { this.params = params @@ -126,6 +127,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -135,52 +137,22 @@ private constructor( fun build(): CustomerCreditTopUpListByExternalIdPageAsync = CustomerCreditTopUpListByExternalIdPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CustomerCreditTopUpListByExternalIdPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (CustomerCreditTopUpListByExternalIdResponse) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList( - executor: Executor - ): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CustomerCreditTopUpListByExternalIdPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CustomerCreditTopUpListByExternalIdPageAsync{service=$service, params=$params, response=$response}" + "CustomerCreditTopUpListByExternalIdPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 fc764c55..47a51cd1 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects @@ -13,14 +12,14 @@ import kotlin.jvm.optionals.getOrNull /** List top-ups by external ID */ class CustomerCreditTopUpListByExternalIdParams private constructor( - private val externalCustomerId: String, + private val externalCustomerId: String?, private val cursor: String?, private val limit: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun externalCustomerId(): String = externalCustomerId + fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the @@ -39,14 +38,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerCreditTopUpListByExternalIdParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerCreditTopUpListByExternalIdParams]. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -73,10 +69,16 @@ private constructor( customerCreditTopUpListByExternalIdParams.additionalQueryParams.toBuilder() } - fun externalCustomerId(externalCustomerId: String) = apply { + fun externalCustomerId(externalCustomerId: String?) = apply { this.externalCustomerId = externalCustomerId } + /** + * Alias for calling [Builder.externalCustomerId] with `externalCustomerId.orElse(null)`. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.getOrNull()) + /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the * initial request. @@ -201,17 +203,10 @@ private constructor( * Returns an immutable instance of [CustomerCreditTopUpListByExternalIdParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerCreditTopUpListByExternalIdParams = CustomerCreditTopUpListByExternalIdParams( - checkRequired("externalCustomerId", externalCustomerId), + externalCustomerId, cursor, limit, additionalHeaders.build(), @@ -221,7 +216,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalCustomerId + 0 -> externalCustomerId ?: "" else -> "" } 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 8b893147..c2b5d7d3 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.customers.credits.TopUpService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [TopUpService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: TopUpService, private val params: CustomerCreditTopUpListParams, private val response: CustomerCreditTopUpListPageResponse, -) { +) : Page { /** * Delegates to [CustomerCreditTopUpListPageResponse], but gracefully handles missing data. @@ -34,31 +34,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditTopUpListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.list(it) } + override fun nextPage(): CustomerCreditTopUpListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CustomerCreditTopUpListParams = params @@ -129,26 +120,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CustomerCreditTopUpListPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 311e993a..fe8e76c4 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [TopUpServiceAsync.list] */ class CustomerCreditTopUpListPageAsync private constructor( private val service: TopUpServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CustomerCreditTopUpListParams, private val response: CustomerCreditTopUpListPageResponse, -) { +) : PageAsync { /** * Delegates to [CustomerCreditTopUpListPageResponse], but gracefully handles missing data. @@ -35,33 +37,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerCreditTopUpListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CustomerCreditTopUpListParams = params @@ -80,6 +73,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -91,6 +85,7 @@ private constructor( class Builder internal constructor() { private var service: TopUpServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CustomerCreditTopUpListParams? = null private var response: CustomerCreditTopUpListPageResponse? = null @@ -98,12 +93,17 @@ private constructor( internal fun from(customerCreditTopUpListPageAsync: CustomerCreditTopUpListPageAsync) = apply { service = customerCreditTopUpListPageAsync.service + streamHandlerExecutor = customerCreditTopUpListPageAsync.streamHandlerExecutor params = customerCreditTopUpListPageAsync.params response = customerCreditTopUpListPageAsync.response } fun service(service: TopUpServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CustomerCreditTopUpListParams) = apply { this.params = params } @@ -120,6 +120,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -129,50 +130,22 @@ private constructor( fun build(): CustomerCreditTopUpListPageAsync = CustomerCreditTopUpListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CustomerCreditTopUpListPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (CustomerCreditTopUpListResponse) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerCreditTopUpListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CustomerCreditTopUpListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CustomerCreditTopUpListPageAsync{service=$service, params=$params, response=$response}" + "CustomerCreditTopUpListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 f8c93c84..4ab5d0aa 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects @@ -13,14 +12,14 @@ import kotlin.jvm.optionals.getOrNull /** List top-ups */ class CustomerCreditTopUpListParams private constructor( - private val customerId: String, + private val customerId: String?, private val cursor: String?, private val limit: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the @@ -39,14 +38,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerCreditTopUpListParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerCreditTopUpListParams]. - * - * The following fields are required: - * ```java - * .customerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -69,7 +65,10 @@ private constructor( additionalQueryParams = customerCreditTopUpListParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the @@ -195,17 +194,10 @@ private constructor( * Returns an immutable instance of [CustomerCreditTopUpListParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerCreditTopUpListParams = CustomerCreditTopUpListParams( - checkRequired("customerId", customerId), + customerId, cursor, limit, additionalHeaders.build(), @@ -215,7 +207,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 e409eece..589a6cfc 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This performs a deletion of this customer, its subscriptions, and its invoices, provided the @@ -28,13 +28,13 @@ import java.util.Optional */ class CustomerDeleteParams private constructor( - private val customerId: String, + private val customerId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -46,14 +46,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CustomerDeleteParams]. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - */ + @JvmStatic fun none(): CustomerDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CustomerDeleteParams]. */ @JvmStatic fun builder() = Builder() } @@ -73,7 +68,10 @@ private constructor( additionalBodyProperties = customerDeleteParams.additionalBodyProperties.toMutableMap() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -199,17 +197,10 @@ private constructor( * Returns an immutable instance of [CustomerDeleteParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerDeleteParams = CustomerDeleteParams( - checkRequired("customerId", customerId), + customerId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -221,7 +212,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 d4d8e8fc..c1a0a7cc 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to fetch customer details given an `external_customer_id` (see @@ -17,12 +18,12 @@ import java.util.Objects */ class CustomerFetchByExternalIdParams private constructor( - private val externalCustomerId: String, + private val externalCustomerId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun externalCustomerId(): String = externalCustomerId + fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) fun _additionalHeaders(): Headers = additionalHeaders @@ -32,14 +33,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerFetchByExternalIdParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerFetchByExternalIdParams]. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -60,10 +58,16 @@ private constructor( customerFetchByExternalIdParams.additionalQueryParams.toBuilder() } - fun externalCustomerId(externalCustomerId: String) = apply { + fun externalCustomerId(externalCustomerId: String?) = apply { this.externalCustomerId = externalCustomerId } + /** + * Alias for calling [Builder.externalCustomerId] with `externalCustomerId.orElse(null)`. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -166,17 +170,10 @@ private constructor( * Returns an immutable instance of [CustomerFetchByExternalIdParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerFetchByExternalIdParams = CustomerFetchByExternalIdParams( - checkRequired("externalCustomerId", externalCustomerId), + externalCustomerId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -184,7 +181,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalCustomerId + 0 -> externalCustomerId ?: "" else -> "" } 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 fdfa378f..5e196bf8 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to fetch customer details given an identifier. If the `Customer` is in the @@ -16,12 +17,12 @@ import java.util.Objects */ class CustomerFetchParams private constructor( - private val customerId: String, + private val customerId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) fun _additionalHeaders(): Headers = additionalHeaders @@ -31,14 +32,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CustomerFetchParams]. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - */ + @JvmStatic fun none(): CustomerFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CustomerFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -56,7 +52,10 @@ private constructor( additionalQueryParams = customerFetchParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -160,17 +159,10 @@ private constructor( * Returns an immutable instance of [CustomerFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerFetchParams = CustomerFetchParams( - checkRequired("customerId", customerId), + customerId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -178,7 +170,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 4f51a3ba..ec69b465 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.CustomerService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [CustomerService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: CustomerService, private val params: CustomerListParams, private val response: CustomerListPageResponse, -) { +) : Page { /** * Delegates to [CustomerListPageResponse], but gracefully handles missing data. @@ -33,30 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): CustomerListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): CustomerListParams = params @@ -125,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: CustomerListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 84928046..ab314321 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.CustomerServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [CustomerServiceAsync.list] */ class CustomerListPageAsync private constructor( private val service: CustomerServiceAsync, + private val streamHandlerExecutor: Executor, private val params: CustomerListParams, private val response: CustomerListPageResponse, -) { +) : PageAsync { /** * Delegates to [CustomerListPageResponse], but gracefully handles missing data. @@ -34,33 +36,23 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): CustomerListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): CustomerListParams = params @@ -78,6 +70,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -89,18 +82,24 @@ private constructor( class Builder internal constructor() { private var service: CustomerServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: CustomerListParams? = null private var response: CustomerListPageResponse? = null @JvmSynthetic internal fun from(customerListPageAsync: CustomerListPageAsync) = apply { service = customerListPageAsync.service + streamHandlerExecutor = customerListPageAsync.streamHandlerExecutor params = customerListPageAsync.params response = customerListPageAsync.response } fun service(service: CustomerServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: CustomerListParams) = apply { this.params = params } @@ -115,6 +114,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -124,47 +124,22 @@ private constructor( fun build(): CustomerListPageAsync = CustomerListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: CustomerListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Customer) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CustomerListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is CustomerListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "CustomerListPageAsync{service=$service, params=$params, response=$response}" + "CustomerListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 d2257aa4..5a614592 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Sync Orb's payment methods for the customer with their gateway. @@ -21,13 +21,13 @@ import java.util.Optional */ class CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams private constructor( - private val externalCustomerId: String, + private val externalCustomerId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun externalCustomerId(): String = externalCustomerId + fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -39,14 +39,13 @@ private constructor( companion object { + @JvmStatic + fun none(): CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = + builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams]. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -79,10 +78,16 @@ private constructor( .toMutableMap() } - fun externalCustomerId(externalCustomerId: String) = apply { + fun externalCustomerId(externalCustomerId: String?) = apply { this.externalCustomerId = externalCustomerId } + /** + * Alias for calling [Builder.externalCustomerId] with `externalCustomerId.orElse(null)`. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -208,17 +213,10 @@ private constructor( * [CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalCustomerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams( - checkRequired("externalCustomerId", externalCustomerId), + externalCustomerId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -230,7 +228,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalCustomerId + 0 -> externalCustomerId ?: "" else -> "" } 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 fc8cf863..12acc9c6 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Sync Orb's payment methods for the customer with their gateway. @@ -21,13 +21,13 @@ import java.util.Optional */ class CustomerSyncPaymentMethodsFromGatewayParams private constructor( - private val customerId: String, + private val customerId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -39,14 +39,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerSyncPaymentMethodsFromGatewayParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerSyncPaymentMethodsFromGatewayParams]. - * - * The following fields are required: - * ```java - * .customerId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -72,7 +69,10 @@ private constructor( customerSyncPaymentMethodsFromGatewayParams.additionalBodyProperties.toMutableMap() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -198,17 +198,10 @@ private constructor( * Returns an immutable instance of [CustomerSyncPaymentMethodsFromGatewayParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerSyncPaymentMethodsFromGatewayParams = CustomerSyncPaymentMethodsFromGatewayParams( - checkRequired("customerId", customerId), + customerId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -220,7 +213,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } 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 abdb287c..4eafe89a 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 @@ -40,13 +40,13 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerUpdateByExternalIdParams private constructor( - private val id: String, + private val id: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun id(): String = id + fun id(): Optional = Optional.ofNullable(id) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -425,14 +425,11 @@ private constructor( companion object { + @JvmStatic fun none(): CustomerUpdateByExternalIdParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [CustomerUpdateByExternalIdParams]. - * - * The following fields are required: - * ```java - * .id() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -455,7 +452,10 @@ private constructor( customerUpdateByExternalIdParams.additionalQueryParams.toBuilder() } - fun id(id: String) = apply { this.id = id } + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) /** * Sets the entire request body. @@ -813,42 +813,38 @@ private constructor( body.taxConfiguration(taxConfiguration) } - /** - * Alias for calling [taxConfiguration] with `TaxConfiguration.ofNewAvalara(newAvalara)`. - */ - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = apply { - body.taxConfiguration(newAvalara) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAvalara(avalara)`. */ + fun taxConfiguration(avalara: TaxConfiguration.Avalara) = apply { + body.taxConfiguration(avalara) } /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewAvalaraTaxConfiguration.builder() - * .taxProvider(CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + * TaxConfiguration.Avalara.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = apply { - body.newAvalaraTaxConfiguration(taxExempt) + fun avalaraTaxConfiguration(taxExempt: Boolean) = apply { + body.avalaraTaxConfiguration(taxExempt) } - /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofNewTaxJar(newTaxJar)`. */ - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = apply { - body.taxConfiguration(newTaxJar) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofTaxjar(taxjar)`. */ + fun taxConfiguration(taxjar: TaxConfiguration.Taxjar) = apply { + body.taxConfiguration(taxjar) } /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewTaxJarConfiguration.builder() - * .taxProvider(CustomerUpdateByExternalIdParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider.TAXJAR) + * TaxConfiguration.Taxjar.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = apply { - body.newTaxJarTaxConfiguration(taxExempt) + fun taxjarTaxConfiguration(taxExempt: Boolean) = apply { + body.taxjarTaxConfiguration(taxExempt) } /** @@ -1091,17 +1087,10 @@ private constructor( * Returns an immutable instance of [CustomerUpdateByExternalIdParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams( - checkRequired("id", id), + id, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -1112,7 +1101,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> id + 0 -> id ?: "" else -> "" } @@ -2025,61 +2014,35 @@ private constructor( this.taxConfiguration = taxConfiguration } - /** - * Alias for calling [taxConfiguration] with - * `TaxConfiguration.ofNewAvalara(newAvalara)`. - */ - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = - taxConfiguration(TaxConfiguration.ofNewAvalara(newAvalara)) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAvalara(avalara)`. */ + fun taxConfiguration(avalara: TaxConfiguration.Avalara) = + taxConfiguration(TaxConfiguration.ofAvalara(avalara)) /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewAvalaraTaxConfiguration.builder() - * .taxProvider(CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + * TaxConfiguration.Avalara.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExempt(taxExempt) - .build() - ) + fun avalaraTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Avalara.builder().taxExempt(taxExempt).build()) - /** - * Alias for calling [taxConfiguration] with `TaxConfiguration.ofNewTaxJar(newTaxJar)`. - */ - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = - taxConfiguration(TaxConfiguration.ofNewTaxJar(newTaxJar)) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofTaxjar(taxjar)`. */ + fun taxConfiguration(taxjar: TaxConfiguration.Taxjar) = + taxConfiguration(TaxConfiguration.ofTaxjar(taxjar)) /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewTaxJarConfiguration.builder() - * .taxProvider(CustomerUpdateByExternalIdParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider.TAXJAR) + * TaxConfiguration.Taxjar.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewTaxJarConfiguration.builder() - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewTaxJarConfiguration - .TaxProvider - .TAXJAR - ) - .taxExempt(taxExempt) - .build() - ) + fun taxjarTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Taxjar.builder().taxExempt(taxExempt).build()) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -4041,29 +4004,29 @@ private constructor( @JsonSerialize(using = TaxConfiguration.Serializer::class) class TaxConfiguration private constructor( - private val newAvalara: NewAvalaraTaxConfiguration? = null, - private val newTaxJar: NewTaxJarConfiguration? = null, + private val avalara: Avalara? = null, + private val taxjar: Taxjar? = null, private val _json: JsonValue? = null, ) { - fun newAvalara(): Optional = Optional.ofNullable(newAvalara) + fun avalara(): Optional = Optional.ofNullable(avalara) - fun newTaxJar(): Optional = Optional.ofNullable(newTaxJar) + fun taxjar(): Optional = Optional.ofNullable(taxjar) - fun isNewAvalara(): Boolean = newAvalara != null + fun isAvalara(): Boolean = avalara != null - fun isNewTaxJar(): Boolean = newTaxJar != null + fun isTaxjar(): Boolean = taxjar != null - fun asNewAvalara(): NewAvalaraTaxConfiguration = newAvalara.getOrThrow("newAvalara") + fun asAvalara(): Avalara = avalara.getOrThrow("avalara") - fun asNewTaxJar(): NewTaxJarConfiguration = newTaxJar.getOrThrow("newTaxJar") + fun asTaxjar(): Taxjar = taxjar.getOrThrow("taxjar") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newAvalara != null -> visitor.visitNewAvalara(newAvalara) - newTaxJar != null -> visitor.visitNewTaxJar(newTaxJar) + avalara != null -> visitor.visitAvalara(avalara) + taxjar != null -> visitor.visitTaxjar(taxjar) else -> visitor.unknown(_json) } @@ -4076,12 +4039,12 @@ private constructor( accept( object : Visitor { - override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) { - newAvalara.validate() + override fun visitAvalara(avalara: Avalara) { + avalara.validate() } - override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) { - newTaxJar.validate() + override fun visitTaxjar(taxjar: Taxjar) { + taxjar.validate() } } ) @@ -4106,11 +4069,9 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = - newAvalara.validity() + override fun visitAvalara(avalara: Avalara) = avalara.validity() - override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) = - newTaxJar.validity() + override fun visitTaxjar(taxjar: Taxjar) = taxjar.validity() override fun unknown(json: JsonValue?) = 0 } @@ -4121,28 +4082,24 @@ private constructor( return true } - return /* spotless:off */ other is TaxConfiguration && newAvalara == other.newAvalara && newTaxJar == other.newTaxJar /* spotless:on */ + return /* spotless:off */ other is TaxConfiguration && avalara == other.avalara && taxjar == other.taxjar /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newAvalara, newTaxJar) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalara, taxjar) /* spotless:on */ override fun toString(): String = when { - newAvalara != null -> "TaxConfiguration{newAvalara=$newAvalara}" - newTaxJar != null -> "TaxConfiguration{newTaxJar=$newTaxJar}" + avalara != null -> "TaxConfiguration{avalara=$avalara}" + taxjar != null -> "TaxConfiguration{taxjar=$taxjar}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } companion object { - @JvmStatic - fun ofNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = - TaxConfiguration(newAvalara = newAvalara) + @JvmStatic fun ofAvalara(avalara: Avalara) = TaxConfiguration(avalara = avalara) - @JvmStatic - fun ofNewTaxJar(newTaxJar: NewTaxJarConfiguration) = - TaxConfiguration(newTaxJar = newTaxJar) + @JvmStatic fun ofTaxjar(taxjar: Taxjar) = TaxConfiguration(taxjar = taxjar) } /** @@ -4151,9 +4108,9 @@ private constructor( */ interface Visitor { - fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration): T + fun visitAvalara(avalara: Avalara): T - fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration): T + fun visitTaxjar(taxjar: Taxjar): T /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. @@ -4179,13 +4136,13 @@ private constructor( when (taxProvider) { "avalara" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { TaxConfiguration(newAvalara = it, _json = json) } - ?: TaxConfiguration(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(avalara = it, _json = json) + } ?: TaxConfiguration(_json = json) } "taxjar" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - TaxConfiguration(newTaxJar = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(taxjar = it, _json = json) } ?: TaxConfiguration(_json = json) } } @@ -4202,18 +4159,18 @@ private constructor( provider: SerializerProvider, ) { when { - value.newAvalara != null -> generator.writeObject(value.newAvalara) - value.newTaxJar != null -> generator.writeObject(value.newTaxJar) + value.avalara != null -> generator.writeObject(value.avalara) + value.taxjar != null -> generator.writeObject(value.taxjar) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } } } - class NewAvalaraTaxConfiguration + class Avalara private constructor( private val taxExempt: JsonField, - private val taxProvider: JsonField, + private val taxProvider: JsonValue, private val taxExemptionCode: JsonField, private val additionalProperties: MutableMap, ) { @@ -4225,7 +4182,7 @@ private constructor( taxExempt: JsonField = JsonMissing.of(), @JsonProperty("tax_provider") @ExcludeMissing - taxProvider: JsonField = JsonMissing.of(), + taxProvider: JsonValue = JsonMissing.of(), @JsonProperty("tax_exemption_code") @ExcludeMissing taxExemptionCode: JsonField = JsonMissing.of(), @@ -4239,11 +4196,17 @@ private constructor( fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("avalara") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -4262,16 +4225,6 @@ private constructor( @ExcludeMissing fun _taxExempt(): JsonField = taxExempt - /** - * Returns the raw JSON value of [taxProvider]. - * - * Unlike [taxProvider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - /** * Returns the raw JSON value of [taxExemptionCode]. * @@ -4297,33 +4250,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewAvalaraTaxConfiguration]. + * Returns a mutable builder for constructing an instance of [Avalara]. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewAvalaraTaxConfiguration]. */ + /** A builder for [Avalara]. */ class Builder internal constructor() { private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("avalara") private var taxExemptionCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newAvalaraTaxConfiguration: NewAvalaraTaxConfiguration) = apply { - taxExempt = newAvalaraTaxConfiguration.taxExempt - taxProvider = newAvalaraTaxConfiguration.taxProvider - taxExemptionCode = newAvalaraTaxConfiguration.taxExemptionCode - additionalProperties = - newAvalaraTaxConfiguration.additionalProperties.toMutableMap() + internal fun from(avalara: Avalara) = apply { + taxExempt = avalara.taxExempt + taxProvider = avalara.taxProvider + taxExemptionCode = avalara.taxExemptionCode + additionalProperties = avalara.additionalProperties.toMutableMap() } fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) @@ -4337,18 +4287,19 @@ private constructor( */ fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - /** - * Sets [Builder.taxProvider] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.taxProvider] with a well-typed [TaxProvider] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("avalara") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } fun taxExemptionCode(taxExemptionCode: String?) = taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) @@ -4394,22 +4345,21 @@ private constructor( } /** - * Returns an immutable instance of [NewAvalaraTaxConfiguration]. + * Returns an immutable instance of [Avalara]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewAvalaraTaxConfiguration = - NewAvalaraTaxConfiguration( + fun build(): Avalara = + Avalara( checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), + taxProvider, taxExemptionCode, additionalProperties.toMutableMap(), ) @@ -4417,13 +4367,17 @@ private constructor( private var validated: Boolean = false - fun validate(): NewAvalaraTaxConfiguration = apply { + fun validate(): Avalara = apply { if (validated) { return@apply } taxExempt() - taxProvider().validate() + _taxProvider().let { + if (it != JsonValue.from("avalara")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } taxExemptionCode() validated = true } @@ -4445,141 +4399,15 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (taxExempt.asKnown().isPresent) 1 else 0) + - (taxProvider.asKnown().getOrNull()?.validity() ?: 0) + + taxProvider.let { if (it == JsonValue.from("avalara")) 1 else 0 } + (if (taxExemptionCode.asKnown().isPresent) 1 else 0) - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AVALARA = of("avalara") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - AVALARA - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AVALARA, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AVALARA -> Value.AVALARA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AVALARA -> Known.AVALARA - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): TaxProvider = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewAvalaraTaxConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Avalara && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4589,13 +4417,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAvalaraTaxConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" + "Avalara{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" } - class NewTaxJarConfiguration + class Taxjar private constructor( private val taxExempt: JsonField, - private val taxProvider: JsonField, + private val taxProvider: JsonValue, private val additionalProperties: MutableMap, ) { @@ -4606,7 +4434,7 @@ private constructor( taxExempt: JsonField = JsonMissing.of(), @JsonProperty("tax_provider") @ExcludeMissing - taxProvider: JsonField = JsonMissing.of(), + taxProvider: JsonValue = JsonMissing.of(), ) : this(taxExempt, taxProvider, mutableMapOf()) /** @@ -4617,11 +4445,17 @@ private constructor( fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("taxjar") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider /** * Returns the raw JSON value of [taxExempt]. @@ -4633,16 +4467,6 @@ private constructor( @ExcludeMissing fun _taxExempt(): JsonField = taxExempt - /** - * Returns the raw JSON value of [taxProvider]. - * - * Unlike [taxProvider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4658,31 +4482,28 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewTaxJarConfiguration]. + * Returns a mutable builder for constructing an instance of [Taxjar]. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewTaxJarConfiguration]. */ + /** A builder for [Taxjar]. */ class Builder internal constructor() { private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("taxjar") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newTaxJarConfiguration: NewTaxJarConfiguration) = apply { - taxExempt = newTaxJarConfiguration.taxExempt - taxProvider = newTaxJarConfiguration.taxProvider - additionalProperties = - newTaxJarConfiguration.additionalProperties.toMutableMap() + internal fun from(taxjar: Taxjar) = apply { + taxExempt = taxjar.taxExempt + taxProvider = taxjar.taxProvider + additionalProperties = taxjar.additionalProperties.toMutableMap() } fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) @@ -4696,18 +4517,19 @@ private constructor( */ fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - /** - * Sets [Builder.taxProvider] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.taxProvider] with a well-typed [TaxProvider] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("taxjar") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4732,35 +4554,38 @@ private constructor( } /** - * Returns an immutable instance of [NewTaxJarConfiguration]. + * Returns an immutable instance of [Taxjar]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewTaxJarConfiguration = - NewTaxJarConfiguration( + fun build(): Taxjar = + Taxjar( checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), + taxProvider, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): NewTaxJarConfiguration = apply { + fun validate(): Taxjar = apply { if (validated) { return@apply } taxExempt() - taxProvider().validate() + _taxProvider().let { + if (it != JsonValue.from("taxjar")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } validated = true } @@ -4781,140 +4606,14 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (taxExempt.asKnown().isPresent) 1 else 0) + - (taxProvider.asKnown().getOrNull()?.validity() ?: 0) - - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 TAXJAR = of("taxjar") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - TAXJAR - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAXJAR, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAXJAR -> Value.TAXJAR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TAXJAR -> Known.TAXJAR - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): TaxProvider = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + taxProvider.let { if (it == JsonValue.from("taxjar")) 1 else 0 } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewTaxJarConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Taxjar && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4924,7 +4623,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewTaxJarConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + "Taxjar{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" } } 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 5e40f2bf..f109905b 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 @@ -41,13 +41,13 @@ import kotlin.jvm.optionals.getOrNull */ class CustomerUpdateParams private constructor( - private val customerId: String, + private val customerId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun customerId(): String = customerId + fun customerId(): Optional = Optional.ofNullable(customerId) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -426,14 +426,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [CustomerUpdateParams]. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - */ + @JvmStatic fun none(): CustomerUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CustomerUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -453,7 +448,10 @@ private constructor( additionalQueryParams = customerUpdateParams.additionalQueryParams.toBuilder() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = apply { this.customerId = customerId } + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) /** * Sets the entire request body. @@ -811,42 +809,38 @@ private constructor( body.taxConfiguration(taxConfiguration) } - /** - * Alias for calling [taxConfiguration] with `TaxConfiguration.ofNewAvalara(newAvalara)`. - */ - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = apply { - body.taxConfiguration(newAvalara) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAvalara(avalara)`. */ + fun taxConfiguration(avalara: TaxConfiguration.Avalara) = apply { + body.taxConfiguration(avalara) } /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewAvalaraTaxConfiguration.builder() - * .taxProvider(CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + * TaxConfiguration.Avalara.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = apply { - body.newAvalaraTaxConfiguration(taxExempt) + fun avalaraTaxConfiguration(taxExempt: Boolean) = apply { + body.avalaraTaxConfiguration(taxExempt) } - /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofNewTaxJar(newTaxJar)`. */ - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = apply { - body.taxConfiguration(newTaxJar) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofTaxjar(taxjar)`. */ + fun taxConfiguration(taxjar: TaxConfiguration.Taxjar) = apply { + body.taxConfiguration(taxjar) } /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewTaxJarConfiguration.builder() - * .taxProvider(CustomerUpdateParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider.TAXJAR) + * TaxConfiguration.Taxjar.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = apply { - body.newTaxJarTaxConfiguration(taxExempt) + fun taxjarTaxConfiguration(taxExempt: Boolean) = apply { + body.taxjarTaxConfiguration(taxExempt) } /** @@ -1089,17 +1083,10 @@ private constructor( * Returns an immutable instance of [CustomerUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .customerId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): CustomerUpdateParams = CustomerUpdateParams( - checkRequired("customerId", customerId), + customerId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -1110,7 +1097,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> customerId + 0 -> customerId ?: "" else -> "" } @@ -2023,59 +2010,35 @@ private constructor( this.taxConfiguration = taxConfiguration } - /** - * Alias for calling [taxConfiguration] with - * `TaxConfiguration.ofNewAvalara(newAvalara)`. - */ - fun taxConfiguration(newAvalara: TaxConfiguration.NewAvalaraTaxConfiguration) = - taxConfiguration(TaxConfiguration.ofNewAvalara(newAvalara)) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofAvalara(avalara)`. */ + fun taxConfiguration(avalara: TaxConfiguration.Avalara) = + taxConfiguration(TaxConfiguration.ofAvalara(avalara)) /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewAvalaraTaxConfiguration.builder() - * .taxProvider(CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider.AVALARA) + * TaxConfiguration.Avalara.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newAvalaraTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewAvalaraTaxConfiguration.builder() - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) - .taxExempt(taxExempt) - .build() - ) + fun avalaraTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Avalara.builder().taxExempt(taxExempt).build()) - /** - * Alias for calling [taxConfiguration] with `TaxConfiguration.ofNewTaxJar(newTaxJar)`. - */ - fun taxConfiguration(newTaxJar: TaxConfiguration.NewTaxJarConfiguration) = - taxConfiguration(TaxConfiguration.ofNewTaxJar(newTaxJar)) + /** Alias for calling [taxConfiguration] with `TaxConfiguration.ofTaxjar(taxjar)`. */ + fun taxConfiguration(taxjar: TaxConfiguration.Taxjar) = + taxConfiguration(TaxConfiguration.ofTaxjar(taxjar)) /** * Alias for calling [taxConfiguration] with the following: * ```java - * TaxConfiguration.NewTaxJarConfiguration.builder() - * .taxProvider(CustomerUpdateParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider.TAXJAR) + * TaxConfiguration.Taxjar.builder() * .taxExempt(taxExempt) * .build() * ``` */ - fun newTaxJarTaxConfiguration(taxExempt: Boolean) = - taxConfiguration( - TaxConfiguration.NewTaxJarConfiguration.builder() - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewTaxJarConfiguration.TaxProvider - .TAXJAR - ) - .taxExempt(taxExempt) - .build() - ) + fun taxjarTaxConfiguration(taxExempt: Boolean) = + taxConfiguration(TaxConfiguration.Taxjar.builder().taxExempt(taxExempt).build()) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -4037,29 +4000,29 @@ private constructor( @JsonSerialize(using = TaxConfiguration.Serializer::class) class TaxConfiguration private constructor( - private val newAvalara: NewAvalaraTaxConfiguration? = null, - private val newTaxJar: NewTaxJarConfiguration? = null, + private val avalara: Avalara? = null, + private val taxjar: Taxjar? = null, private val _json: JsonValue? = null, ) { - fun newAvalara(): Optional = Optional.ofNullable(newAvalara) + fun avalara(): Optional = Optional.ofNullable(avalara) - fun newTaxJar(): Optional = Optional.ofNullable(newTaxJar) + fun taxjar(): Optional = Optional.ofNullable(taxjar) - fun isNewAvalara(): Boolean = newAvalara != null + fun isAvalara(): Boolean = avalara != null - fun isNewTaxJar(): Boolean = newTaxJar != null + fun isTaxjar(): Boolean = taxjar != null - fun asNewAvalara(): NewAvalaraTaxConfiguration = newAvalara.getOrThrow("newAvalara") + fun asAvalara(): Avalara = avalara.getOrThrow("avalara") - fun asNewTaxJar(): NewTaxJarConfiguration = newTaxJar.getOrThrow("newTaxJar") + fun asTaxjar(): Taxjar = taxjar.getOrThrow("taxjar") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newAvalara != null -> visitor.visitNewAvalara(newAvalara) - newTaxJar != null -> visitor.visitNewTaxJar(newTaxJar) + avalara != null -> visitor.visitAvalara(avalara) + taxjar != null -> visitor.visitTaxjar(taxjar) else -> visitor.unknown(_json) } @@ -4072,12 +4035,12 @@ private constructor( accept( object : Visitor { - override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) { - newAvalara.validate() + override fun visitAvalara(avalara: Avalara) { + avalara.validate() } - override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) { - newTaxJar.validate() + override fun visitTaxjar(taxjar: Taxjar) { + taxjar.validate() } } ) @@ -4102,11 +4065,9 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = - newAvalara.validity() + override fun visitAvalara(avalara: Avalara) = avalara.validity() - override fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration) = - newTaxJar.validity() + override fun visitTaxjar(taxjar: Taxjar) = taxjar.validity() override fun unknown(json: JsonValue?) = 0 } @@ -4117,28 +4078,24 @@ private constructor( return true } - return /* spotless:off */ other is TaxConfiguration && newAvalara == other.newAvalara && newTaxJar == other.newTaxJar /* spotless:on */ + return /* spotless:off */ other is TaxConfiguration && avalara == other.avalara && taxjar == other.taxjar /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newAvalara, newTaxJar) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(avalara, taxjar) /* spotless:on */ override fun toString(): String = when { - newAvalara != null -> "TaxConfiguration{newAvalara=$newAvalara}" - newTaxJar != null -> "TaxConfiguration{newTaxJar=$newTaxJar}" + avalara != null -> "TaxConfiguration{avalara=$avalara}" + taxjar != null -> "TaxConfiguration{taxjar=$taxjar}" _json != null -> "TaxConfiguration{_unknown=$_json}" else -> throw IllegalStateException("Invalid TaxConfiguration") } companion object { - @JvmStatic - fun ofNewAvalara(newAvalara: NewAvalaraTaxConfiguration) = - TaxConfiguration(newAvalara = newAvalara) + @JvmStatic fun ofAvalara(avalara: Avalara) = TaxConfiguration(avalara = avalara) - @JvmStatic - fun ofNewTaxJar(newTaxJar: NewTaxJarConfiguration) = - TaxConfiguration(newTaxJar = newTaxJar) + @JvmStatic fun ofTaxjar(taxjar: Taxjar) = TaxConfiguration(taxjar = taxjar) } /** @@ -4147,9 +4104,9 @@ private constructor( */ interface Visitor { - fun visitNewAvalara(newAvalara: NewAvalaraTaxConfiguration): T + fun visitAvalara(avalara: Avalara): T - fun visitNewTaxJar(newTaxJar: NewTaxJarConfiguration): T + fun visitTaxjar(taxjar: Taxjar): T /** * Maps an unknown variant of [TaxConfiguration] to a value of type [T]. @@ -4175,13 +4132,13 @@ private constructor( when (taxProvider) { "avalara" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { TaxConfiguration(newAvalara = it, _json = json) } - ?: TaxConfiguration(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(avalara = it, _json = json) + } ?: TaxConfiguration(_json = json) } "taxjar" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - TaxConfiguration(newTaxJar = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + TaxConfiguration(taxjar = it, _json = json) } ?: TaxConfiguration(_json = json) } } @@ -4198,18 +4155,18 @@ private constructor( provider: SerializerProvider, ) { when { - value.newAvalara != null -> generator.writeObject(value.newAvalara) - value.newTaxJar != null -> generator.writeObject(value.newTaxJar) + value.avalara != null -> generator.writeObject(value.avalara) + value.taxjar != null -> generator.writeObject(value.taxjar) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid TaxConfiguration") } } } - class NewAvalaraTaxConfiguration + class Avalara private constructor( private val taxExempt: JsonField, - private val taxProvider: JsonField, + private val taxProvider: JsonValue, private val taxExemptionCode: JsonField, private val additionalProperties: MutableMap, ) { @@ -4221,7 +4178,7 @@ private constructor( taxExempt: JsonField = JsonMissing.of(), @JsonProperty("tax_provider") @ExcludeMissing - taxProvider: JsonField = JsonMissing.of(), + taxProvider: JsonValue = JsonMissing.of(), @JsonProperty("tax_exemption_code") @ExcludeMissing taxExemptionCode: JsonField = JsonMissing.of(), @@ -4235,11 +4192,17 @@ private constructor( fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("avalara") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -4258,16 +4221,6 @@ private constructor( @ExcludeMissing fun _taxExempt(): JsonField = taxExempt - /** - * Returns the raw JSON value of [taxProvider]. - * - * Unlike [taxProvider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - /** * Returns the raw JSON value of [taxExemptionCode]. * @@ -4293,33 +4246,30 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewAvalaraTaxConfiguration]. + * Returns a mutable builder for constructing an instance of [Avalara]. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewAvalaraTaxConfiguration]. */ + /** A builder for [Avalara]. */ class Builder internal constructor() { private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("avalara") private var taxExemptionCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newAvalaraTaxConfiguration: NewAvalaraTaxConfiguration) = apply { - taxExempt = newAvalaraTaxConfiguration.taxExempt - taxProvider = newAvalaraTaxConfiguration.taxProvider - taxExemptionCode = newAvalaraTaxConfiguration.taxExemptionCode - additionalProperties = - newAvalaraTaxConfiguration.additionalProperties.toMutableMap() + internal fun from(avalara: Avalara) = apply { + taxExempt = avalara.taxExempt + taxProvider = avalara.taxProvider + taxExemptionCode = avalara.taxExemptionCode + additionalProperties = avalara.additionalProperties.toMutableMap() } fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) @@ -4333,18 +4283,19 @@ private constructor( */ fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - /** - * Sets [Builder.taxProvider] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.taxProvider] with a well-typed [TaxProvider] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("avalara") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } fun taxExemptionCode(taxExemptionCode: String?) = taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) @@ -4390,22 +4341,21 @@ private constructor( } /** - * Returns an immutable instance of [NewAvalaraTaxConfiguration]. + * Returns an immutable instance of [Avalara]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewAvalaraTaxConfiguration = - NewAvalaraTaxConfiguration( + fun build(): Avalara = + Avalara( checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), + taxProvider, taxExemptionCode, additionalProperties.toMutableMap(), ) @@ -4413,13 +4363,17 @@ private constructor( private var validated: Boolean = false - fun validate(): NewAvalaraTaxConfiguration = apply { + fun validate(): Avalara = apply { if (validated) { return@apply } taxExempt() - taxProvider().validate() + _taxProvider().let { + if (it != JsonValue.from("avalara")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } taxExemptionCode() validated = true } @@ -4441,141 +4395,15 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (taxExempt.asKnown().isPresent) 1 else 0) + - (taxProvider.asKnown().getOrNull()?.validity() ?: 0) + + taxProvider.let { if (it == JsonValue.from("avalara")) 1 else 0 } + (if (taxExemptionCode.asKnown().isPresent) 1 else 0) - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AVALARA = of("avalara") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - AVALARA - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AVALARA, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AVALARA -> Value.AVALARA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AVALARA -> Known.AVALARA - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): TaxProvider = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewAvalaraTaxConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Avalara && taxExempt == other.taxExempt && taxProvider == other.taxProvider && taxExemptionCode == other.taxExemptionCode && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4585,13 +4413,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAvalaraTaxConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" + "Avalara{taxExempt=$taxExempt, taxProvider=$taxProvider, taxExemptionCode=$taxExemptionCode, additionalProperties=$additionalProperties}" } - class NewTaxJarConfiguration + class Taxjar private constructor( private val taxExempt: JsonField, - private val taxProvider: JsonField, + private val taxProvider: JsonValue, private val additionalProperties: MutableMap, ) { @@ -4602,7 +4430,7 @@ private constructor( taxExempt: JsonField = JsonMissing.of(), @JsonProperty("tax_provider") @ExcludeMissing - taxProvider: JsonField = JsonMissing.of(), + taxProvider: JsonValue = JsonMissing.of(), ) : this(taxExempt, taxProvider, mutableMapOf()) /** @@ -4613,11 +4441,17 @@ private constructor( fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("taxjar") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonValue = taxProvider /** * Returns the raw JSON value of [taxExempt]. @@ -4629,16 +4463,6 @@ private constructor( @ExcludeMissing fun _taxExempt(): JsonField = taxExempt - /** - * Returns the raw JSON value of [taxProvider]. - * - * Unlike [taxProvider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tax_provider") - @ExcludeMissing - fun _taxProvider(): JsonField = taxProvider - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4654,31 +4478,28 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewTaxJarConfiguration]. + * Returns a mutable builder for constructing an instance of [Taxjar]. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewTaxJarConfiguration]. */ + /** A builder for [Taxjar]. */ class Builder internal constructor() { private var taxExempt: JsonField? = null - private var taxProvider: JsonField? = null + private var taxProvider: JsonValue = JsonValue.from("taxjar") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newTaxJarConfiguration: NewTaxJarConfiguration) = apply { - taxExempt = newTaxJarConfiguration.taxExempt - taxProvider = newTaxJarConfiguration.taxProvider - additionalProperties = - newTaxJarConfiguration.additionalProperties.toMutableMap() + internal fun from(taxjar: Taxjar) = apply { + taxExempt = taxjar.taxExempt + taxProvider = taxjar.taxProvider + additionalProperties = taxjar.additionalProperties.toMutableMap() } fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) @@ -4692,18 +4513,19 @@ private constructor( */ fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) - /** - * Sets [Builder.taxProvider] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.taxProvider] with a well-typed [TaxProvider] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("taxjar") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun taxProvider(taxProvider: JsonField) = apply { - this.taxProvider = taxProvider - } + fun taxProvider(taxProvider: JsonValue) = apply { this.taxProvider = taxProvider } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4728,35 +4550,38 @@ private constructor( } /** - * Returns an immutable instance of [NewTaxJarConfiguration]. + * Returns an immutable instance of [Taxjar]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .taxExempt() - * .taxProvider() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewTaxJarConfiguration = - NewTaxJarConfiguration( + fun build(): Taxjar = + Taxjar( checkRequired("taxExempt", taxExempt), - checkRequired("taxProvider", taxProvider), + taxProvider, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): NewTaxJarConfiguration = apply { + fun validate(): Taxjar = apply { if (validated) { return@apply } taxExempt() - taxProvider().validate() + _taxProvider().let { + if (it != JsonValue.from("taxjar")) { + throw OrbInvalidDataException("'taxProvider' is invalid, received $it") + } + } validated = true } @@ -4777,140 +4602,14 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (taxExempt.asKnown().isPresent) 1 else 0) + - (taxProvider.asKnown().getOrNull()?.validity() ?: 0) - - class TaxProvider - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 TAXJAR = of("taxjar") - - @JvmStatic fun of(value: String) = TaxProvider(JsonField.of(value)) - } - - /** An enum containing [TaxProvider]'s known values. */ - enum class Known { - TAXJAR - } - - /** - * An enum containing [TaxProvider]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxProvider] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TAXJAR, - /** - * An enum member indicating that [TaxProvider] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TAXJAR -> Value.TAXJAR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TAXJAR -> Known.TAXJAR - else -> throw OrbInvalidDataException("Unknown TaxProvider: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): TaxProvider = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is TaxProvider && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + taxProvider.let { if (it == JsonValue.from("taxjar")) 1 else 0 } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewTaxJarConfiguration && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Taxjar && taxExempt == other.taxExempt && taxProvider == other.taxProvider && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4920,7 +4619,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewTaxJarConfiguration{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" + "Taxjar{taxExempt=$taxExempt, taxProvider=$taxProvider, additionalProperties=$additionalProperties}" } } 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 2ede0606..81584e94 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 @@ -3,20 +3,22 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Fetch dimensional price group by external ID */ class DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams private constructor( - private val externalDimensionalPriceGroupId: String, + private val externalDimensionalPriceGroupId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun externalDimensionalPriceGroupId(): String = externalDimensionalPriceGroupId + fun externalDimensionalPriceGroupId(): Optional = + Optional.ofNullable(externalDimensionalPriceGroupId) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +28,13 @@ private constructor( companion object { + @JvmStatic + fun none(): DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = + builder().build() + /** * Returns a mutable builder for constructing an instance of * [DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams]. - * - * The following fields are required: - * ```java - * .externalDimensionalPriceGroupId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -62,10 +63,17 @@ private constructor( .toBuilder() } - fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: String) = apply { + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: String?) = apply { this.externalDimensionalPriceGroupId = externalDimensionalPriceGroupId } + /** + * Alias for calling [Builder.externalDimensionalPriceGroupId] with + * `externalDimensionalPriceGroupId.orElse(null)`. + */ + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: Optional) = + externalDimensionalPriceGroupId(externalDimensionalPriceGroupId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -169,17 +177,10 @@ private constructor( * [DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalDimensionalPriceGroupId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams( - checkRequired("externalDimensionalPriceGroupId", externalDimensionalPriceGroupId), + externalDimensionalPriceGroupId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -187,7 +188,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalDimensionalPriceGroupId + 0 -> externalDimensionalPriceGroupId ?: "" else -> "" } 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 7d685ba5..899015d7 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.DimensionalPriceGroupService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [DimensionalPriceGroupService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: DimensionalPriceGroupService, private val params: DimensionalPriceGroupListParams, private val response: DimensionalPriceGroups, -) { +) : Page { /** * Delegates to [DimensionalPriceGroups], but gracefully handles missing data. @@ -34,31 +34,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): DimensionalPriceGroupListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.list(it) } + override fun nextPage(): DimensionalPriceGroupListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): DimensionalPriceGroupListParams = params @@ -128,26 +119,6 @@ private constructor( ) } - class AutoPager(private val firstPage: DimensionalPriceGroupListPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 a823786c..4575dde4 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.DimensionalPriceGroupServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [DimensionalPriceGroupServiceAsync.list] */ class DimensionalPriceGroupListPageAsync private constructor( private val service: DimensionalPriceGroupServiceAsync, + private val streamHandlerExecutor: Executor, private val params: DimensionalPriceGroupListParams, private val response: DimensionalPriceGroups, -) { +) : PageAsync { /** * Delegates to [DimensionalPriceGroups], but gracefully handles missing data. @@ -35,33 +37,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): DimensionalPriceGroupListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): DimensionalPriceGroupListParams = params @@ -80,6 +73,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -91,6 +85,7 @@ private constructor( class Builder internal constructor() { private var service: DimensionalPriceGroupServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: DimensionalPriceGroupListParams? = null private var response: DimensionalPriceGroups? = null @@ -98,12 +93,17 @@ private constructor( internal fun from(dimensionalPriceGroupListPageAsync: DimensionalPriceGroupListPageAsync) = apply { service = dimensionalPriceGroupListPageAsync.service + streamHandlerExecutor = dimensionalPriceGroupListPageAsync.streamHandlerExecutor params = dimensionalPriceGroupListPageAsync.params response = dimensionalPriceGroupListPageAsync.response } fun service(service: DimensionalPriceGroupServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: DimensionalPriceGroupListParams) = apply { this.params = params } @@ -118,6 +118,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -127,50 +128,22 @@ private constructor( fun build(): DimensionalPriceGroupListPageAsync = DimensionalPriceGroupListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: DimensionalPriceGroupListPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (DimensionalPriceGroup) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is DimensionalPriceGroupListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is DimensionalPriceGroupListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "DimensionalPriceGroupListPageAsync{service=$service, params=$params, response=$response}" + "DimensionalPriceGroupListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 80e454bd..9e5cfe97 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 @@ -3,20 +3,21 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Fetch dimensional price group */ class DimensionalPriceGroupRetrieveParams private constructor( - private val dimensionalPriceGroupId: String, + private val dimensionalPriceGroupId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun dimensionalPriceGroupId(): String = dimensionalPriceGroupId + fun dimensionalPriceGroupId(): Optional = Optional.ofNullable(dimensionalPriceGroupId) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,11 @@ private constructor( companion object { + @JvmStatic fun none(): DimensionalPriceGroupRetrieveParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [DimensionalPriceGroupRetrieveParams]. - * - * The following fields are required: - * ```java - * .dimensionalPriceGroupId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -55,10 +53,17 @@ private constructor( dimensionalPriceGroupRetrieveParams.additionalQueryParams.toBuilder() } - fun dimensionalPriceGroupId(dimensionalPriceGroupId: String) = apply { + fun dimensionalPriceGroupId(dimensionalPriceGroupId: String?) = apply { this.dimensionalPriceGroupId = dimensionalPriceGroupId } + /** + * Alias for calling [Builder.dimensionalPriceGroupId] with + * `dimensionalPriceGroupId.orElse(null)`. + */ + fun dimensionalPriceGroupId(dimensionalPriceGroupId: Optional) = + dimensionalPriceGroupId(dimensionalPriceGroupId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -161,17 +166,10 @@ private constructor( * Returns an immutable instance of [DimensionalPriceGroupRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .dimensionalPriceGroupId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): DimensionalPriceGroupRetrieveParams = DimensionalPriceGroupRetrieveParams( - checkRequired("dimensionalPriceGroupId", dimensionalPriceGroupId), + dimensionalPriceGroupId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -179,7 +177,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> dimensionalPriceGroupId + 0 -> dimensionalPriceGroupId ?: "" else -> "" } 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 c97664fb..65c4381d 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Closing a backfill makes the updated usage visible in Orb. Upon closing a backfill, Orb will @@ -18,13 +18,13 @@ import java.util.Optional */ class EventBackfillCloseParams private constructor( - private val backfillId: String, + private val backfillId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun backfillId(): String = backfillId + fun backfillId(): Optional = Optional.ofNullable(backfillId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [EventBackfillCloseParams]. - * - * The following fields are required: - * ```java - * .backfillId() - * ``` - */ + @JvmStatic fun none(): EventBackfillCloseParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EventBackfillCloseParams]. */ @JvmStatic fun builder() = Builder() } @@ -64,7 +59,10 @@ private constructor( eventBackfillCloseParams.additionalBodyProperties.toMutableMap() } - fun backfillId(backfillId: String) = apply { this.backfillId = backfillId } + fun backfillId(backfillId: String?) = apply { this.backfillId = backfillId } + + /** Alias for calling [Builder.backfillId] with `backfillId.orElse(null)`. */ + fun backfillId(backfillId: Optional) = backfillId(backfillId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -190,17 +188,10 @@ private constructor( * Returns an immutable instance of [EventBackfillCloseParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .backfillId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EventBackfillCloseParams = EventBackfillCloseParams( - checkRequired("backfillId", backfillId), + backfillId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -212,7 +203,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> backfillId + 0 -> backfillId ?: "" else -> "" } 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 30794a55..51ce1789 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 @@ -3,20 +3,21 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** This endpoint is used to fetch a backfill given an identifier. */ class EventBackfillFetchParams private constructor( - private val backfillId: String, + private val backfillId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun backfillId(): String = backfillId + fun backfillId(): Optional = Optional.ofNullable(backfillId) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [EventBackfillFetchParams]. - * - * The following fields are required: - * ```java - * .backfillId() - * ``` - */ + @JvmStatic fun none(): EventBackfillFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EventBackfillFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = eventBackfillFetchParams.additionalQueryParams.toBuilder() } - fun backfillId(backfillId: String) = apply { this.backfillId = backfillId } + fun backfillId(backfillId: String?) = apply { this.backfillId = backfillId } + + /** Alias for calling [Builder.backfillId] with `backfillId.orElse(null)`. */ + fun backfillId(backfillId: Optional) = backfillId(backfillId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,17 +154,10 @@ private constructor( * Returns an immutable instance of [EventBackfillFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .backfillId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EventBackfillFetchParams = EventBackfillFetchParams( - checkRequired("backfillId", backfillId), + backfillId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -173,7 +165,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> backfillId + 0 -> backfillId ?: "" else -> "" } 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 bfcc8636..68258174 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.events.BackfillService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [BackfillService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: BackfillService, private val params: EventBackfillListParams, private val response: EventBackfillListPageResponse, -) { +) : Page { /** * Delegates to [EventBackfillListPageResponse], but gracefully handles missing data. @@ -34,31 +34,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): EventBackfillListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.list(it) } + override fun nextPage(): EventBackfillListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): EventBackfillListParams = params @@ -127,26 +118,6 @@ private constructor( ) } - class AutoPager(private val firstPage: EventBackfillListPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 21a3d253..c2175ff8 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.events.BackfillServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [BackfillServiceAsync.list] */ class EventBackfillListPageAsync private constructor( private val service: BackfillServiceAsync, + private val streamHandlerExecutor: Executor, private val params: EventBackfillListParams, private val response: EventBackfillListPageResponse, -) { +) : PageAsync { /** * Delegates to [EventBackfillListPageResponse], but gracefully handles missing data. @@ -35,33 +37,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): EventBackfillListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): EventBackfillListParams = params @@ -79,6 +72,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -90,18 +84,24 @@ private constructor( class Builder internal constructor() { private var service: BackfillServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: EventBackfillListParams? = null private var response: EventBackfillListPageResponse? = null @JvmSynthetic internal fun from(eventBackfillListPageAsync: EventBackfillListPageAsync) = apply { service = eventBackfillListPageAsync.service + streamHandlerExecutor = eventBackfillListPageAsync.streamHandlerExecutor params = eventBackfillListPageAsync.params response = eventBackfillListPageAsync.response } fun service(service: BackfillServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: EventBackfillListParams) = apply { this.params = params } @@ -116,6 +116,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -125,50 +126,22 @@ private constructor( fun build(): EventBackfillListPageAsync = EventBackfillListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: EventBackfillListPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (EventBackfillListResponse) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is EventBackfillListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is EventBackfillListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "EventBackfillListPageAsync{service=$service, params=$params, response=$response}" + "EventBackfillListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 2e450d0d..6eb57fe2 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Reverting a backfill undoes all the effects of closing the backfill. If the backfill is @@ -21,13 +21,13 @@ import java.util.Optional */ class EventBackfillRevertParams private constructor( - private val backfillId: String, + private val backfillId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun backfillId(): String = backfillId + fun backfillId(): Optional = Optional.ofNullable(backfillId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -39,13 +39,10 @@ private constructor( companion object { + @JvmStatic fun none(): EventBackfillRevertParams = builder().build() + /** * Returns a mutable builder for constructing an instance of [EventBackfillRevertParams]. - * - * The following fields are required: - * ```java - * .backfillId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -67,7 +64,10 @@ private constructor( eventBackfillRevertParams.additionalBodyProperties.toMutableMap() } - fun backfillId(backfillId: String) = apply { this.backfillId = backfillId } + fun backfillId(backfillId: String?) = apply { this.backfillId = backfillId } + + /** Alias for calling [Builder.backfillId] with `backfillId.orElse(null)`. */ + fun backfillId(backfillId: Optional) = backfillId(backfillId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -193,17 +193,10 @@ private constructor( * Returns an immutable instance of [EventBackfillRevertParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .backfillId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EventBackfillRevertParams = EventBackfillRevertParams( - checkRequired("backfillId", backfillId), + backfillId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -215,7 +208,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> backfillId + 0 -> backfillId ?: "" else -> "" } 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 acb0ed12..5b8d9e4f 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to deprecate a single usage event with a given `event_id`. `event_id` @@ -47,13 +47,13 @@ import java.util.Optional */ class EventDeprecateParams private constructor( - private val eventId: String, + private val eventId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun eventId(): String = eventId + fun eventId(): Optional = Optional.ofNullable(eventId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -65,14 +65,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [EventDeprecateParams]. - * - * The following fields are required: - * ```java - * .eventId() - * ``` - */ + @JvmStatic fun none(): EventDeprecateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [EventDeprecateParams]. */ @JvmStatic fun builder() = Builder() } @@ -92,7 +87,10 @@ private constructor( additionalBodyProperties = eventDeprecateParams.additionalBodyProperties.toMutableMap() } - fun eventId(eventId: String) = apply { this.eventId = eventId } + fun eventId(eventId: String?) = apply { this.eventId = eventId } + + /** Alias for calling [Builder.eventId] with `eventId.orElse(null)`. */ + fun eventId(eventId: Optional) = eventId(eventId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -218,17 +216,10 @@ private constructor( * Returns an immutable instance of [EventDeprecateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .eventId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): EventDeprecateParams = EventDeprecateParams( - checkRequired("eventId", eventId), + eventId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -240,7 +231,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> eventId + 0 -> eventId ?: "" else -> "" } 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 80e738e8..7aa72535 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 @@ -62,13 +62,13 @@ import kotlin.jvm.optionals.getOrNull */ class EventUpdateParams private constructor( - private val eventId: String, + private val eventId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun eventId(): String = eventId + fun eventId(): Optional = Optional.ofNullable(eventId) /** * A name to meaningfully identify the action or event type. @@ -154,7 +154,6 @@ private constructor( * * The following fields are required: * ```java - * .eventId() * .eventName() * .properties() * .timestamp() @@ -179,7 +178,10 @@ private constructor( additionalQueryParams = eventUpdateParams.additionalQueryParams.toBuilder() } - fun eventId(eventId: String) = apply { this.eventId = eventId } + fun eventId(eventId: String?) = apply { this.eventId = eventId } + + /** Alias for calling [Builder.eventId] with `eventId.orElse(null)`. */ + fun eventId(eventId: Optional) = eventId(eventId.getOrNull()) /** * Sets the entire request body. @@ -390,7 +392,6 @@ private constructor( * * The following fields are required: * ```java - * .eventId() * .eventName() * .properties() * .timestamp() @@ -400,7 +401,7 @@ private constructor( */ fun build(): EventUpdateParams = EventUpdateParams( - checkRequired("eventId", eventId), + eventId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -411,7 +412,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> eventId + 0 -> eventId ?: "" else -> "" } 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 6af774be..71e7ab8a 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 @@ -6885,40 +6885,31 @@ private constructor( } /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryUsageDiscount(monetaryUsageDiscount)`. + * Alias for calling [addAdjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun addAdjustment(monetaryUsageDiscount: Adjustment.MonetaryUsageDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryUsageDiscount(monetaryUsageDiscount)) + fun addAdjustment(usageDiscount: Adjustment.UsageDiscount) = + addAdjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryAmountDiscount(monetaryAmountDiscount)`. + * Alias for calling [addAdjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun addAdjustment(monetaryAmountDiscount: Adjustment.MonetaryAmountDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryAmountDiscount(monetaryAmountDiscount)) + fun addAdjustment(amountDiscount: Adjustment.AmountDiscount) = + addAdjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryPercentageDiscount(monetaryPercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun addAdjustment( - monetaryPercentageDiscount: Adjustment.MonetaryPercentageDiscountAdjustment - ) = addAdjustment(Adjustment.ofMonetaryPercentageDiscount(monetaryPercentageDiscount)) + fun addAdjustment(percentageDiscount: Adjustment.PercentageDiscount) = + addAdjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryMinimum(monetaryMinimum)`. - */ - fun addAdjustment(monetaryMinimum: Adjustment.MonetaryMinimumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMinimum(monetaryMinimum)) + /** Alias for calling [addAdjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun addAdjustment(minimum: Adjustment.Minimum) = + addAdjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryMaximum(monetaryMaximum)`. - */ - fun addAdjustment(monetaryMaximum: Adjustment.MonetaryMaximumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMaximum(monetaryMaximum)) + /** Alias for calling [addAdjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun addAdjustment(maximum: Adjustment.Maximum) = + addAdjustment(Adjustment.ofMaximum(maximum)) /** * The final amount for a line item after all adjustments and pre paid credits have been @@ -7174,142 +7165,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** Either the fixed fee quantity or the usage during the service period. */ @@ -7369,16 +7360,14 @@ private constructor( } /** Alias for calling [addSubLineItem] with `SubLineItem.ofMatrix(matrix)`. */ - fun addSubLineItem(matrix: SubLineItem.MatrixSubLineItem) = + fun addSubLineItem(matrix: SubLineItem.Matrix) = addSubLineItem(SubLineItem.ofMatrix(matrix)) /** Alias for calling [addSubLineItem] with `SubLineItem.ofTier(tier)`. */ - fun addSubLineItem(tier: SubLineItem.TierSubLineItem) = - addSubLineItem(SubLineItem.ofTier(tier)) + fun addSubLineItem(tier: SubLineItem.Tier) = addSubLineItem(SubLineItem.ofTier(tier)) - /** Alias for calling [addSubLineItem] with `SubLineItem.ofOther(other)`. */ - fun addSubLineItem(other: SubLineItem.OtherSubLineItem) = - addSubLineItem(SubLineItem.ofOther(other)) + /** Alias for calling [addSubLineItem] with `SubLineItem.ofNull(null_)`. */ + fun addSubLineItem(null_: SubLineItem.Null) = addSubLineItem(SubLineItem.ofNull(null_)) /** The line amount before before any adjustments. */ fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) @@ -7609,66 +7598,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val monetaryUsageDiscount: MonetaryUsageDiscountAdjustment? = null, - private val monetaryAmountDiscount: MonetaryAmountDiscountAdjustment? = null, - private val monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment? = null, - private val monetaryMinimum: MonetaryMinimumAdjustment? = null, - private val monetaryMaximum: MonetaryMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun monetaryUsageDiscount(): Optional = - Optional.ofNullable(monetaryUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun monetaryAmountDiscount(): Optional = - Optional.ofNullable(monetaryAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun monetaryPercentageDiscount(): Optional = - Optional.ofNullable(monetaryPercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun monetaryMinimum(): Optional = - Optional.ofNullable(monetaryMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun monetaryMaximum(): Optional = - Optional.ofNullable(monetaryMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isMonetaryUsageDiscount(): Boolean = monetaryUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isMonetaryAmountDiscount(): Boolean = monetaryAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isMonetaryPercentageDiscount(): Boolean = monetaryPercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isMonetaryMinimum(): Boolean = monetaryMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isMonetaryMaximum(): Boolean = monetaryMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asMonetaryUsageDiscount(): MonetaryUsageDiscountAdjustment = - monetaryUsageDiscount.getOrThrow("monetaryUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asMonetaryAmountDiscount(): MonetaryAmountDiscountAdjustment = - monetaryAmountDiscount.getOrThrow("monetaryAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asMonetaryPercentageDiscount(): MonetaryPercentageDiscountAdjustment = - monetaryPercentageDiscount.getOrThrow("monetaryPercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asMonetaryMinimum(): MonetaryMinimumAdjustment = - monetaryMinimum.getOrThrow("monetaryMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asMonetaryMaximum(): MonetaryMaximumAdjustment = - monetaryMaximum.getOrThrow("monetaryMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - monetaryUsageDiscount != null -> - visitor.visitMonetaryUsageDiscount(monetaryUsageDiscount) - monetaryAmountDiscount != null -> - visitor.visitMonetaryAmountDiscount(monetaryAmountDiscount) - monetaryPercentageDiscount != null -> - visitor.visitMonetaryPercentageDiscount(monetaryPercentageDiscount) - monetaryMinimum != null -> visitor.visitMonetaryMinimum(monetaryMinimum) - monetaryMaximum != null -> visitor.visitMonetaryMaximum(monetaryMaximum) + 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) } @@ -7681,34 +7660,26 @@ private constructor( accept( object : Visitor { - override fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) { - monetaryUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) { - monetaryAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - monetaryPercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitMonetaryMinimum( - monetaryMinimum: MonetaryMinimumAdjustment - ) { - monetaryMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitMonetaryMaximum( - monetaryMaximum: MonetaryMaximumAdjustment - ) { - monetaryMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -7733,25 +7704,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) = monetaryUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) = monetaryAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) = monetaryPercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitMonetaryMinimum( - monetaryMinimum: MonetaryMinimumAdjustment - ) = monetaryMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitMonetaryMaximum( - monetaryMaximum: MonetaryMaximumAdjustment - ) = monetaryMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -7762,21 +7727,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && monetaryUsageDiscount == other.monetaryUsageDiscount && monetaryAmountDiscount == other.monetaryAmountDiscount && monetaryPercentageDiscount == other.monetaryPercentageDiscount && monetaryMinimum == other.monetaryMinimum && monetaryMaximum == other.monetaryMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(monetaryUsageDiscount, monetaryAmountDiscount, monetaryPercentageDiscount, monetaryMinimum, monetaryMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - monetaryUsageDiscount != null -> - "Adjustment{monetaryUsageDiscount=$monetaryUsageDiscount}" - monetaryAmountDiscount != null -> - "Adjustment{monetaryAmountDiscount=$monetaryAmountDiscount}" - monetaryPercentageDiscount != null -> - "Adjustment{monetaryPercentageDiscount=$monetaryPercentageDiscount}" - monetaryMinimum != null -> "Adjustment{monetaryMinimum=$monetaryMinimum}" - monetaryMaximum != null -> "Adjustment{monetaryMaximum=$monetaryMaximum}" + 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") } @@ -7784,27 +7747,20 @@ private constructor( companion object { @JvmStatic - fun ofMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) = Adjustment(monetaryUsageDiscount = monetaryUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) = Adjustment(monetaryAmountDiscount = monetaryAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) = Adjustment(monetaryPercentageDiscount = monetaryPercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment) = - Adjustment(monetaryMinimum = monetaryMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment) = - Adjustment(monetaryMaximum = monetaryMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -7813,21 +7769,15 @@ private constructor( */ interface Visitor { - fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -7853,38 +7803,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(monetaryUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(monetaryAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(monetaryPercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(monetaryMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(monetaryMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -7900,26 +7841,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.monetaryUsageDiscount != null -> - generator.writeObject(value.monetaryUsageDiscount) - value.monetaryAmountDiscount != null -> - generator.writeObject(value.monetaryAmountDiscount) - value.monetaryPercentageDiscount != null -> - generator.writeObject(value.monetaryPercentageDiscount) - value.monetaryMinimum != null -> - generator.writeObject(value.monetaryMinimum) - value.monetaryMaximum != null -> - generator.writeObject(value.monetaryMaximum) + 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") } } } - class MonetaryUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -7933,7 +7870,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -7968,11 +7905,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -8028,16 +7971,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -8099,13 +8032,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -8116,11 +8047,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -8129,21 +8060,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - monetaryUsageDiscountAdjustment: MonetaryUsageDiscountAdjustment - ) = apply { - id = monetaryUsageDiscountAdjustment.id - adjustmentType = monetaryUsageDiscountAdjustment.adjustmentType - amount = monetaryUsageDiscountAdjustment.amount + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType + amount = usageDiscount.amount appliesToPriceIds = - monetaryUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryUsageDiscountAdjustment.isInvoiceLevel - reason = monetaryUsageDiscountAdjustment.reason - usageDiscount = monetaryUsageDiscountAdjustment.usageDiscount - additionalProperties = - monetaryUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -8157,17 +8083,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -8284,14 +8212,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -8301,10 +8228,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryUsageDiscountAdjustment = - MonetaryUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -8318,13 +8245,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -8350,149 +8283,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -8502,13 +8307,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class MonetaryAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, @@ -8522,7 +8327,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -8557,11 +8362,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -8617,16 +8428,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -8688,13 +8489,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .amountDiscount() * .appliesToPriceIds() @@ -8705,11 +8504,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amount: JsonField? = null private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null @@ -8718,21 +8517,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - monetaryAmountDiscountAdjustment: MonetaryAmountDiscountAdjustment - ) = apply { - id = monetaryAmountDiscountAdjustment.id - adjustmentType = monetaryAmountDiscountAdjustment.adjustmentType - amount = monetaryAmountDiscountAdjustment.amount - amountDiscount = monetaryAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + amount = amountDiscount.amount + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - monetaryAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryAmountDiscountAdjustment.isInvoiceLevel - reason = monetaryAmountDiscountAdjustment.reason - additionalProperties = - monetaryAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -8746,17 +8540,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("amount_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -8873,14 +8669,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .amountDiscount() * .appliesToPriceIds() @@ -8890,10 +8685,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryAmountDiscountAdjustment = - MonetaryAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { @@ -8907,13 +8702,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() amountDiscount() appliesToPriceIds() @@ -8939,149 +8740,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amount.asKnown().isPresent) 1 else 0) + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -9091,13 +8764,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amount=$amount, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, additionalProperties=$additionalProperties}" } - class MonetaryPercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -9111,7 +8784,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -9146,11 +8819,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -9207,16 +8886,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -9279,12 +8948,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MonetaryPercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -9295,11 +8963,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryPercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -9308,21 +8976,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - monetaryPercentageDiscountAdjustment: MonetaryPercentageDiscountAdjustment - ) = apply { - id = monetaryPercentageDiscountAdjustment.id - adjustmentType = monetaryPercentageDiscountAdjustment.adjustmentType - amount = monetaryPercentageDiscountAdjustment.amount + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType + amount = percentageDiscount.amount appliesToPriceIds = - monetaryPercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryPercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = monetaryPercentageDiscountAdjustment.percentageDiscount - reason = monetaryPercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + reason = percentageDiscount.reason additionalProperties = - monetaryPercentageDiscountAdjustment.additionalProperties.toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -9336,17 +9000,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -9463,14 +9129,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryPercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -9480,10 +9145,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryPercentageDiscountAdjustment = - MonetaryPercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -9497,13 +9162,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryPercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -9529,165 +9200,37 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, percentageDiscount, reason, additionalProperties) } + /* spotless:on */ - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } + override fun hashCode(): Int = hashCode - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } + override fun toString() = + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, reason=$reason, additionalProperties=$additionalProperties}" + } - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryPercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, percentageDiscount, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryPercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, reason=$reason, additionalProperties=$additionalProperties}" - } - - class MonetaryMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -9702,7 +9245,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -9741,11 +9284,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -9810,16 +9359,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -9889,13 +9428,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -9907,11 +9444,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -9921,22 +9458,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(monetaryMinimumAdjustment: MonetaryMinimumAdjustment) = - apply { - id = monetaryMinimumAdjustment.id - adjustmentType = monetaryMinimumAdjustment.adjustmentType - amount = monetaryMinimumAdjustment.amount - appliesToPriceIds = - monetaryMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryMinimumAdjustment.isInvoiceLevel - itemId = monetaryMinimumAdjustment.itemId - minimumAmount = monetaryMinimumAdjustment.minimumAmount - reason = monetaryMinimumAdjustment.reason - additionalProperties = - monetaryMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + amount = minimum.amount + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -9949,17 +9481,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -10088,14 +9622,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -10106,10 +9639,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryMinimumAdjustment = - MonetaryMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -10124,13 +9657,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -10157,7 +9696,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + @@ -10165,142 +9704,12 @@ private constructor( (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -10310,13 +9719,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, reason=$reason, additionalProperties=$additionalProperties}" } - class MonetaryMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -10330,7 +9739,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -10365,11 +9774,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -10425,16 +9840,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -10496,13 +9901,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -10513,11 +9916,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -10526,21 +9929,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(monetaryMaximumAdjustment: MonetaryMaximumAdjustment) = - apply { - id = monetaryMaximumAdjustment.id - adjustmentType = monetaryMaximumAdjustment.adjustmentType - amount = monetaryMaximumAdjustment.amount - appliesToPriceIds = - monetaryMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryMaximumAdjustment.isInvoiceLevel - maximumAmount = monetaryMaximumAdjustment.maximumAmount - reason = monetaryMaximumAdjustment.reason - additionalProperties = - monetaryMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + amount = maximum.amount + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -10553,17 +9951,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -10680,14 +10080,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -10697,10 +10096,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryMaximumAdjustment = - MonetaryMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -10714,13 +10113,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -10746,149 +10151,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -10898,7 +10173,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -11382,29 +10657,29 @@ private constructor( @JsonSerialize(using = SubLineItem.Serializer::class) class SubLineItem private constructor( - private val matrix: MatrixSubLineItem? = null, - private val tier: TierSubLineItem? = null, - private val other: OtherSubLineItem? = null, + private val matrix: Matrix? = null, + private val tier: Tier? = null, + private val null_: Null? = null, private val _json: JsonValue? = null, ) { - fun matrix(): Optional = Optional.ofNullable(matrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun tier(): Optional = Optional.ofNullable(tier) + fun tier(): Optional = Optional.ofNullable(tier) - fun other(): Optional = Optional.ofNullable(other) + fun null_(): Optional = Optional.ofNullable(null_) fun isMatrix(): Boolean = matrix != null fun isTier(): Boolean = tier != null - fun isOther(): Boolean = other != null + fun isNull(): Boolean = null_ != null - fun asMatrix(): MatrixSubLineItem = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asTier(): TierSubLineItem = tier.getOrThrow("tier") + fun asTier(): Tier = tier.getOrThrow("tier") - fun asOther(): OtherSubLineItem = other.getOrThrow("other") + fun asNull(): Null = null_.getOrThrow("null_") fun _json(): Optional = Optional.ofNullable(_json) @@ -11412,7 +10687,7 @@ private constructor( when { matrix != null -> visitor.visitMatrix(matrix) tier != null -> visitor.visitTier(tier) - other != null -> visitor.visitOther(other) + null_ != null -> visitor.visitNull(null_) else -> visitor.unknown(_json) } @@ -11425,16 +10700,16 @@ private constructor( accept( object : Visitor { - override fun visitMatrix(matrix: MatrixSubLineItem) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } - override fun visitTier(tier: TierSubLineItem) { + override fun visitTier(tier: Tier) { tier.validate() } - override fun visitOther(other: OtherSubLineItem) { - other.validate() + override fun visitNull(null_: Null) { + null_.validate() } } ) @@ -11459,11 +10734,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitMatrix(matrix: MatrixSubLineItem) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() - override fun visitTier(tier: TierSubLineItem) = tier.validity() + override fun visitTier(tier: Tier) = tier.validity() - override fun visitOther(other: OtherSubLineItem) = other.validity() + override fun visitNull(null_: Null) = null_.validity() override fun unknown(json: JsonValue?) = 0 } @@ -11474,27 +10749,27 @@ private constructor( return true } - return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && this.other == other.other /* spotless:on */ + return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && null_ == other.null_ /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, other) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, null_) /* spotless:on */ override fun toString(): String = when { matrix != null -> "SubLineItem{matrix=$matrix}" tier != null -> "SubLineItem{tier=$tier}" - other != null -> "SubLineItem{other=$other}" + 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 ofMatrix(matrix: Matrix) = SubLineItem(matrix = matrix) - @JvmStatic fun ofTier(tier: TierSubLineItem) = SubLineItem(tier = tier) + @JvmStatic fun ofTier(tier: Tier) = SubLineItem(tier = tier) - @JvmStatic fun ofOther(other: OtherSubLineItem) = SubLineItem(other = other) + @JvmStatic fun ofNull(null_: Null) = SubLineItem(null_ = null_) } /** @@ -11503,11 +10778,11 @@ private constructor( */ interface Visitor { - fun visitMatrix(matrix: MatrixSubLineItem): T + fun visitMatrix(matrix: Matrix): T - fun visitTier(tier: TierSubLineItem): T + fun visitTier(tier: Tier): T - fun visitOther(other: OtherSubLineItem): T + fun visitNull(null_: Null): T /** * Maps an unknown variant of [SubLineItem] to a value of type [T]. @@ -11532,18 +10807,18 @@ private constructor( when (type) { "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { SubLineItem(matrix = it, _json = json) } ?: SubLineItem(_json = json) } "tier" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { SubLineItem(tier = it, _json = json) } ?: SubLineItem(_json = json) } "'null'" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - SubLineItem(other = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(null_ = it, _json = json) } ?: SubLineItem(_json = json) } } @@ -11562,21 +10837,21 @@ private constructor( when { value.matrix != null -> generator.writeObject(value.matrix) value.tier != null -> generator.writeObject(value.tier) - value.other != null -> generator.writeObject(value.other) + value.null_ != null -> generator.writeObject(value.null_) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid SubLineItem") } } } - class MatrixSubLineItem + class Matrix private constructor( private val amount: JsonField, private val grouping: JsonField, private val matrixConfig: JsonField, private val name: JsonField, private val quantity: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -11597,7 +10872,7 @@ private constructor( @JsonProperty("quantity") @ExcludeMissing quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(amount, grouping, matrixConfig, name, quantity, type, mutableMapOf()) /** @@ -11637,11 +10912,15 @@ private constructor( fun quantity(): Double = quantity.getRequired("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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [amount]. @@ -11689,14 +10968,6 @@ private constructor( @ExcludeMissing fun _quantity(): JsonField = quantity - /** - * 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) @@ -11712,8 +10983,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MatrixSubLineItem]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java @@ -11722,13 +10992,12 @@ private constructor( * .matrixConfig() * .name() * .quantity() - * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixSubLineItem]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var amount: JsonField? = null @@ -11736,18 +11005,18 @@ private constructor( private var matrixConfig: JsonField? = null private var name: JsonField? = null private var quantity: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("matrix") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixSubLineItem: MatrixSubLineItem) = apply { - amount = matrixSubLineItem.amount - grouping = matrixSubLineItem.grouping - matrixConfig = matrixSubLineItem.matrixConfig - name = matrixSubLineItem.name - quantity = matrixSubLineItem.quantity - type = matrixSubLineItem.type - additionalProperties = matrixSubLineItem.additionalProperties.toMutableMap() + internal fun from(matrix: Matrix) = apply { + amount = matrix.amount + grouping = matrix.grouping + matrixConfig = matrix.matrixConfig + name = matrix.name + quantity = matrix.quantity + type = matrix.type + additionalProperties = matrix.additionalProperties.toMutableMap() } /** The total amount for this sub line item. */ @@ -11812,16 +11081,19 @@ private constructor( */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * 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("matrix") + * ``` * - * 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. + * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -11846,7 +11118,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixSubLineItem]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -11857,26 +11129,25 @@ private constructor( * .matrixConfig() * .name() * .quantity() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixSubLineItem = - MatrixSubLineItem( + fun build(): Matrix = + Matrix( checkRequired("amount", amount), checkRequired("grouping", grouping), checkRequired("matrixConfig", matrixConfig), checkRequired("name", name), checkRequired("quantity", quantity), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): MatrixSubLineItem = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -11886,7 +11157,11 @@ private constructor( matrixConfig().validate() name() quantity() - type().validate() + _type().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -11911,7 +11186,7 @@ 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.let { if (it == JsonValue.from("matrix")) 1 else 0 } class Grouping private constructor( @@ -12312,139 +11587,12 @@ private constructor( "MatrixConfig{dimensionValues=$dimensionValues, additionalProperties=$additionalProperties}" } - 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 MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is 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 /* spotless:off */ other is Matrix && amount == other.amount && grouping == other.grouping && matrixConfig == other.matrixConfig && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -12454,17 +11602,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixSubLineItem{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" + "Matrix{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" } - class TierSubLineItem + class Tier private constructor( private val amount: JsonField, private val grouping: JsonField, private val name: JsonField, private val quantity: JsonField, private val tierConfig: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -12485,7 +11633,7 @@ private constructor( @JsonProperty("tier_config") @ExcludeMissing tierConfig: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(amount, grouping, name, quantity, tierConfig, type, mutableMapOf()) /** @@ -12525,11 +11673,15 @@ private constructor( fun tierConfig(): TierConfig = tierConfig.getRequired("tier_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). + * Expected to always return the following: + * ```java + * JsonValue.from("tier") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [amount]. @@ -12577,14 +11729,6 @@ private constructor( @ExcludeMissing fun _tierConfig(): JsonField = tierConfig - /** - * 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) @@ -12600,7 +11744,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TierSubLineItem]. + * Returns a mutable builder for constructing an instance of [Tier]. * * The following fields are required: * ```java @@ -12609,13 +11753,12 @@ private constructor( * .name() * .quantity() * .tierConfig() - * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TierSubLineItem]. */ + /** A builder for [Tier]. */ class Builder internal constructor() { private var amount: JsonField? = null @@ -12623,18 +11766,18 @@ private constructor( private var name: JsonField? = null private var quantity: JsonField? = null private var tierConfig: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("tier") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tierSubLineItem: TierSubLineItem) = apply { - amount = tierSubLineItem.amount - grouping = tierSubLineItem.grouping - name = tierSubLineItem.name - quantity = tierSubLineItem.quantity - tierConfig = tierSubLineItem.tierConfig - type = tierSubLineItem.type - additionalProperties = tierSubLineItem.additionalProperties.toMutableMap() + internal fun from(tier: Tier) = apply { + amount = tier.amount + grouping = tier.grouping + name = tier.name + quantity = tier.quantity + tierConfig = tier.tierConfig + type = tier.type + additionalProperties = tier.additionalProperties.toMutableMap() } /** The total amount for this sub line item. */ @@ -12698,16 +11841,19 @@ private constructor( this.tierConfig = tierConfig } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tier") + * ``` + * + * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -12732,7 +11878,7 @@ private constructor( } /** - * Returns an immutable instance of [TierSubLineItem]. + * Returns an immutable instance of [Tier]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -12743,26 +11889,25 @@ private constructor( * .name() * .quantity() * .tierConfig() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TierSubLineItem = - TierSubLineItem( + fun build(): Tier = + Tier( checkRequired("amount", amount), checkRequired("grouping", grouping), checkRequired("name", name), checkRequired("quantity", quantity), checkRequired("tierConfig", tierConfig), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TierSubLineItem = apply { + fun validate(): Tier = apply { if (validated) { return@apply } @@ -12772,7 +11917,11 @@ private constructor( name() quantity() tierConfig().validate() - type().validate() + _type().let { + if (it != JsonValue.from("tier")) { + throw OrbInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -12797,7 +11946,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + (tierConfig.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("tier")) 1 else 0 } class Grouping private constructor( @@ -13266,139 +12415,12 @@ private constructor( "TierConfig{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - 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 TIER = of("tier") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TIER - } - - /** - * 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 { - TIER, - /** - * 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) { - TIER -> Value.TIER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIER -> Known.TIER - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is 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 /* spotless:off */ other is Tier && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && tierConfig == other.tierConfig && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -13408,16 +12430,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TierSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, tierConfig=$tierConfig, type=$type, additionalProperties=$additionalProperties}" + "Tier{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, tierConfig=$tierConfig, type=$type, additionalProperties=$additionalProperties}" } - class OtherSubLineItem + class Null private constructor( private val amount: JsonField, private val grouping: JsonField, private val name: JsonField, private val quantity: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -13435,7 +12457,7 @@ private constructor( @JsonProperty("quantity") @ExcludeMissing quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(amount, grouping, name, quantity, type, mutableMapOf()) /** @@ -13468,11 +12490,15 @@ private constructor( fun quantity(): Double = quantity.getRequired("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). + * Expected to always return the following: + * ```java + * JsonValue.from("'null'") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [amount]. @@ -13510,14 +12536,6 @@ private constructor( @ExcludeMissing fun _quantity(): JsonField = quantity - /** - * 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) @@ -13533,7 +12551,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [OtherSubLineItem]. + * Returns a mutable builder for constructing an instance of [Null]. * * The following fields are required: * ```java @@ -13541,30 +12559,29 @@ private constructor( * .grouping() * .name() * .quantity() - * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [OtherSubLineItem]. */ + /** A builder for [Null]. */ class Builder internal constructor() { private var amount: JsonField? = null private var grouping: JsonField? = null private var name: JsonField? = null private var quantity: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("'null'") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(otherSubLineItem: OtherSubLineItem) = apply { - amount = otherSubLineItem.amount - grouping = otherSubLineItem.grouping - name = otherSubLineItem.name - quantity = otherSubLineItem.quantity - type = otherSubLineItem.type - additionalProperties = otherSubLineItem.additionalProperties.toMutableMap() + internal fun from(null_: Null) = apply { + amount = null_.amount + grouping = null_.grouping + name = null_.name + quantity = null_.quantity + type = null_.type + additionalProperties = null_.additionalProperties.toMutableMap() } /** The total amount for this sub line item. */ @@ -13615,16 +12632,19 @@ private constructor( */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("'null'") + * ``` + * + * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -13649,7 +12669,7 @@ private constructor( } /** - * Returns an immutable instance of [OtherSubLineItem]. + * Returns an immutable instance of [Null]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -13659,25 +12679,24 @@ private constructor( * .grouping() * .name() * .quantity() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): OtherSubLineItem = - OtherSubLineItem( + fun build(): Null = + Null( checkRequired("amount", amount), checkRequired("grouping", grouping), checkRequired("name", name), checkRequired("quantity", quantity), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): OtherSubLineItem = apply { + fun validate(): Null = apply { if (validated) { return@apply } @@ -13686,7 +12705,11 @@ private constructor( grouping().ifPresent { it.validate() } name() quantity() - type().validate() + _type().let { + if (it != JsonValue.from("'null'")) { + throw OrbInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -13710,7 +12733,7 @@ private constructor( (grouping.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("'null'")) 1 else 0 } class Grouping private constructor( @@ -13919,139 +12942,12 @@ private constructor( "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" } - 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 NULL = of("'null'") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - NULL - } - - /** - * 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 { - NULL, - /** - * 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) { - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - NULL -> Known.NULL - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is OtherSubLineItem && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Null && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -14061,7 +12957,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OtherSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" + "Null{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" } } 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 4b2fee35..88d3083a 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 @@ -3,20 +3,21 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an identifier. */ class InvoiceFetchParams private constructor( - private val invoiceId: String, + private val invoiceId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun invoiceId(): String = invoiceId + fun invoiceId(): Optional = Optional.ofNullable(invoiceId) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [InvoiceFetchParams]. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - */ + @JvmStatic fun none(): InvoiceFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InvoiceFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = invoiceFetchParams.additionalQueryParams.toBuilder() } - fun invoiceId(invoiceId: String) = apply { this.invoiceId = invoiceId } + fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } + + /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,25 +154,14 @@ private constructor( * Returns an immutable instance of [InvoiceFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): InvoiceFetchParams = - InvoiceFetchParams( - checkRequired("invoiceId", invoiceId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + InvoiceFetchParams(invoiceId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> invoiceId + 0 -> invoiceId ?: "" else -> "" } 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 c45d7264..67dcc592 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 @@ -6876,40 +6876,31 @@ private constructor( } /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryUsageDiscount(monetaryUsageDiscount)`. + * Alias for calling [addAdjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun addAdjustment(monetaryUsageDiscount: Adjustment.MonetaryUsageDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryUsageDiscount(monetaryUsageDiscount)) + fun addAdjustment(usageDiscount: Adjustment.UsageDiscount) = + addAdjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryAmountDiscount(monetaryAmountDiscount)`. + * Alias for calling [addAdjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun addAdjustment(monetaryAmountDiscount: Adjustment.MonetaryAmountDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryAmountDiscount(monetaryAmountDiscount)) + fun addAdjustment(amountDiscount: Adjustment.AmountDiscount) = + addAdjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryPercentageDiscount(monetaryPercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun addAdjustment( - monetaryPercentageDiscount: Adjustment.MonetaryPercentageDiscountAdjustment - ) = addAdjustment(Adjustment.ofMonetaryPercentageDiscount(monetaryPercentageDiscount)) + fun addAdjustment(percentageDiscount: Adjustment.PercentageDiscount) = + addAdjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryMinimum(monetaryMinimum)`. - */ - fun addAdjustment(monetaryMinimum: Adjustment.MonetaryMinimumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMinimum(monetaryMinimum)) + /** Alias for calling [addAdjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun addAdjustment(minimum: Adjustment.Minimum) = + addAdjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryMaximum(monetaryMaximum)`. - */ - fun addAdjustment(monetaryMaximum: Adjustment.MonetaryMaximumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMaximum(monetaryMaximum)) + /** Alias for calling [addAdjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun addAdjustment(maximum: Adjustment.Maximum) = + addAdjustment(Adjustment.ofMaximum(maximum)) /** * The final amount for a line item after all adjustments and pre paid credits have been @@ -7165,142 +7156,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** Either the fixed fee quantity or the usage during the service period. */ @@ -7360,16 +7351,14 @@ private constructor( } /** Alias for calling [addSubLineItem] with `SubLineItem.ofMatrix(matrix)`. */ - fun addSubLineItem(matrix: SubLineItem.MatrixSubLineItem) = + fun addSubLineItem(matrix: SubLineItem.Matrix) = addSubLineItem(SubLineItem.ofMatrix(matrix)) /** Alias for calling [addSubLineItem] with `SubLineItem.ofTier(tier)`. */ - fun addSubLineItem(tier: SubLineItem.TierSubLineItem) = - addSubLineItem(SubLineItem.ofTier(tier)) + fun addSubLineItem(tier: SubLineItem.Tier) = addSubLineItem(SubLineItem.ofTier(tier)) - /** Alias for calling [addSubLineItem] with `SubLineItem.ofOther(other)`. */ - fun addSubLineItem(other: SubLineItem.OtherSubLineItem) = - addSubLineItem(SubLineItem.ofOther(other)) + /** Alias for calling [addSubLineItem] with `SubLineItem.ofNull(null_)`. */ + fun addSubLineItem(null_: SubLineItem.Null) = addSubLineItem(SubLineItem.ofNull(null_)) /** The line amount before before any adjustments. */ fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) @@ -7600,66 +7589,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val monetaryUsageDiscount: MonetaryUsageDiscountAdjustment? = null, - private val monetaryAmountDiscount: MonetaryAmountDiscountAdjustment? = null, - private val monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment? = null, - private val monetaryMinimum: MonetaryMinimumAdjustment? = null, - private val monetaryMaximum: MonetaryMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun monetaryUsageDiscount(): Optional = - Optional.ofNullable(monetaryUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun monetaryAmountDiscount(): Optional = - Optional.ofNullable(monetaryAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun monetaryPercentageDiscount(): Optional = - Optional.ofNullable(monetaryPercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun monetaryMinimum(): Optional = - Optional.ofNullable(monetaryMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun monetaryMaximum(): Optional = - Optional.ofNullable(monetaryMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isMonetaryUsageDiscount(): Boolean = monetaryUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isMonetaryAmountDiscount(): Boolean = monetaryAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isMonetaryPercentageDiscount(): Boolean = monetaryPercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isMonetaryMinimum(): Boolean = monetaryMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isMonetaryMaximum(): Boolean = monetaryMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asMonetaryUsageDiscount(): MonetaryUsageDiscountAdjustment = - monetaryUsageDiscount.getOrThrow("monetaryUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asMonetaryAmountDiscount(): MonetaryAmountDiscountAdjustment = - monetaryAmountDiscount.getOrThrow("monetaryAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asMonetaryPercentageDiscount(): MonetaryPercentageDiscountAdjustment = - monetaryPercentageDiscount.getOrThrow("monetaryPercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asMonetaryMinimum(): MonetaryMinimumAdjustment = - monetaryMinimum.getOrThrow("monetaryMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asMonetaryMaximum(): MonetaryMaximumAdjustment = - monetaryMaximum.getOrThrow("monetaryMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - monetaryUsageDiscount != null -> - visitor.visitMonetaryUsageDiscount(monetaryUsageDiscount) - monetaryAmountDiscount != null -> - visitor.visitMonetaryAmountDiscount(monetaryAmountDiscount) - monetaryPercentageDiscount != null -> - visitor.visitMonetaryPercentageDiscount(monetaryPercentageDiscount) - monetaryMinimum != null -> visitor.visitMonetaryMinimum(monetaryMinimum) - monetaryMaximum != null -> visitor.visitMonetaryMaximum(monetaryMaximum) + 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) } @@ -7672,34 +7651,26 @@ private constructor( accept( object : Visitor { - override fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) { - monetaryUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) { - monetaryAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - monetaryPercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitMonetaryMinimum( - monetaryMinimum: MonetaryMinimumAdjustment - ) { - monetaryMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitMonetaryMaximum( - monetaryMaximum: MonetaryMaximumAdjustment - ) { - monetaryMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -7724,25 +7695,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) = monetaryUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) = monetaryAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) = monetaryPercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitMonetaryMinimum( - monetaryMinimum: MonetaryMinimumAdjustment - ) = monetaryMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitMonetaryMaximum( - monetaryMaximum: MonetaryMaximumAdjustment - ) = monetaryMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -7753,21 +7718,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && monetaryUsageDiscount == other.monetaryUsageDiscount && monetaryAmountDiscount == other.monetaryAmountDiscount && monetaryPercentageDiscount == other.monetaryPercentageDiscount && monetaryMinimum == other.monetaryMinimum && monetaryMaximum == other.monetaryMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(monetaryUsageDiscount, monetaryAmountDiscount, monetaryPercentageDiscount, monetaryMinimum, monetaryMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - monetaryUsageDiscount != null -> - "Adjustment{monetaryUsageDiscount=$monetaryUsageDiscount}" - monetaryAmountDiscount != null -> - "Adjustment{monetaryAmountDiscount=$monetaryAmountDiscount}" - monetaryPercentageDiscount != null -> - "Adjustment{monetaryPercentageDiscount=$monetaryPercentageDiscount}" - monetaryMinimum != null -> "Adjustment{monetaryMinimum=$monetaryMinimum}" - monetaryMaximum != null -> "Adjustment{monetaryMaximum=$monetaryMaximum}" + 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") } @@ -7775,27 +7738,20 @@ private constructor( companion object { @JvmStatic - fun ofMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) = Adjustment(monetaryUsageDiscount = monetaryUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) = Adjustment(monetaryAmountDiscount = monetaryAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) = Adjustment(monetaryPercentageDiscount = monetaryPercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment) = - Adjustment(monetaryMinimum = monetaryMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment) = - Adjustment(monetaryMaximum = monetaryMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -7804,21 +7760,15 @@ private constructor( */ interface Visitor { - fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -7844,38 +7794,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(monetaryUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(monetaryAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(monetaryPercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(monetaryMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(monetaryMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -7891,26 +7832,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.monetaryUsageDiscount != null -> - generator.writeObject(value.monetaryUsageDiscount) - value.monetaryAmountDiscount != null -> - generator.writeObject(value.monetaryAmountDiscount) - value.monetaryPercentageDiscount != null -> - generator.writeObject(value.monetaryPercentageDiscount) - value.monetaryMinimum != null -> - generator.writeObject(value.monetaryMinimum) - value.monetaryMaximum != null -> - generator.writeObject(value.monetaryMaximum) + 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") } } } - class MonetaryUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -7924,7 +7861,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -7959,11 +7896,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -8019,16 +7962,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -8090,13 +8023,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -8107,11 +8038,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -8120,21 +8051,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - monetaryUsageDiscountAdjustment: MonetaryUsageDiscountAdjustment - ) = apply { - id = monetaryUsageDiscountAdjustment.id - adjustmentType = monetaryUsageDiscountAdjustment.adjustmentType - amount = monetaryUsageDiscountAdjustment.amount + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType + amount = usageDiscount.amount appliesToPriceIds = - monetaryUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryUsageDiscountAdjustment.isInvoiceLevel - reason = monetaryUsageDiscountAdjustment.reason - usageDiscount = monetaryUsageDiscountAdjustment.usageDiscount - additionalProperties = - monetaryUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -8148,17 +8074,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -8275,14 +8203,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -8292,10 +8219,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryUsageDiscountAdjustment = - MonetaryUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -8309,13 +8236,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -8341,149 +8274,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -8493,13 +8298,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class MonetaryAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, @@ -8513,7 +8318,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -8548,11 +8353,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -8608,16 +8419,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -8679,13 +8480,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .amountDiscount() * .appliesToPriceIds() @@ -8696,11 +8495,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amount: JsonField? = null private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null @@ -8709,21 +8508,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - monetaryAmountDiscountAdjustment: MonetaryAmountDiscountAdjustment - ) = apply { - id = monetaryAmountDiscountAdjustment.id - adjustmentType = monetaryAmountDiscountAdjustment.adjustmentType - amount = monetaryAmountDiscountAdjustment.amount - amountDiscount = monetaryAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + amount = amountDiscount.amount + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - monetaryAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryAmountDiscountAdjustment.isInvoiceLevel - reason = monetaryAmountDiscountAdjustment.reason - additionalProperties = - monetaryAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -8737,17 +8531,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("amount_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -8864,14 +8660,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .amountDiscount() * .appliesToPriceIds() @@ -8881,10 +8676,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryAmountDiscountAdjustment = - MonetaryAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { @@ -8898,13 +8693,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() amountDiscount() appliesToPriceIds() @@ -8930,149 +8731,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amount.asKnown().isPresent) 1 else 0) + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -9082,13 +8755,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amount=$amount, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, additionalProperties=$additionalProperties}" } - class MonetaryPercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -9102,7 +8775,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -9137,11 +8810,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -9198,16 +8877,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -9270,12 +8939,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [MonetaryPercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -9286,11 +8954,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryPercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -9299,21 +8967,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - monetaryPercentageDiscountAdjustment: MonetaryPercentageDiscountAdjustment - ) = apply { - id = monetaryPercentageDiscountAdjustment.id - adjustmentType = monetaryPercentageDiscountAdjustment.adjustmentType - amount = monetaryPercentageDiscountAdjustment.amount + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType + amount = percentageDiscount.amount appliesToPriceIds = - monetaryPercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryPercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = monetaryPercentageDiscountAdjustment.percentageDiscount - reason = monetaryPercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + reason = percentageDiscount.reason additionalProperties = - monetaryPercentageDiscountAdjustment.additionalProperties.toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -9327,17 +8991,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -9454,14 +9120,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryPercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -9471,10 +9136,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryPercentageDiscountAdjustment = - MonetaryPercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -9488,13 +9153,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryPercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -9520,165 +9191,37 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - companion object { + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, percentageDiscount, reason, additionalProperties) } + /* spotless:on */ - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } + override fun hashCode(): Int = hashCode - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } + override fun toString() = + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, reason=$reason, additionalProperties=$additionalProperties}" + } - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryPercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, percentageDiscount, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryPercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, reason=$reason, additionalProperties=$additionalProperties}" - } - - class MonetaryMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -9693,7 +9236,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -9732,11 +9275,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -9801,16 +9350,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -9880,13 +9419,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -9898,11 +9435,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -9912,22 +9449,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(monetaryMinimumAdjustment: MonetaryMinimumAdjustment) = - apply { - id = monetaryMinimumAdjustment.id - adjustmentType = monetaryMinimumAdjustment.adjustmentType - amount = monetaryMinimumAdjustment.amount - appliesToPriceIds = - monetaryMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryMinimumAdjustment.isInvoiceLevel - itemId = monetaryMinimumAdjustment.itemId - minimumAmount = monetaryMinimumAdjustment.minimumAmount - reason = monetaryMinimumAdjustment.reason - additionalProperties = - monetaryMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + amount = minimum.amount + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -9940,17 +9472,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -10079,14 +9613,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -10097,10 +9630,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryMinimumAdjustment = - MonetaryMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -10115,13 +9648,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -10148,7 +9687,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + @@ -10156,142 +9695,12 @@ private constructor( (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -10301,13 +9710,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, reason=$reason, additionalProperties=$additionalProperties}" } - class MonetaryMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -10321,7 +9730,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -10356,11 +9765,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -10416,16 +9831,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -10487,13 +9892,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -10504,11 +9907,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -10517,21 +9920,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(monetaryMaximumAdjustment: MonetaryMaximumAdjustment) = - apply { - id = monetaryMaximumAdjustment.id - adjustmentType = monetaryMaximumAdjustment.adjustmentType - amount = monetaryMaximumAdjustment.amount - appliesToPriceIds = - monetaryMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryMaximumAdjustment.isInvoiceLevel - maximumAmount = monetaryMaximumAdjustment.maximumAmount - reason = monetaryMaximumAdjustment.reason - additionalProperties = - monetaryMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + amount = maximum.amount + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -10544,17 +9942,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -10671,14 +10071,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -10688,10 +10087,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryMaximumAdjustment = - MonetaryMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -10705,13 +10104,19 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -10737,149 +10142,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -10889,7 +10164,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -11373,29 +10648,29 @@ private constructor( @JsonSerialize(using = SubLineItem.Serializer::class) class SubLineItem private constructor( - private val matrix: MatrixSubLineItem? = null, - private val tier: TierSubLineItem? = null, - private val other: OtherSubLineItem? = null, + private val matrix: Matrix? = null, + private val tier: Tier? = null, + private val null_: Null? = null, private val _json: JsonValue? = null, ) { - fun matrix(): Optional = Optional.ofNullable(matrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun tier(): Optional = Optional.ofNullable(tier) + fun tier(): Optional = Optional.ofNullable(tier) - fun other(): Optional = Optional.ofNullable(other) + fun null_(): Optional = Optional.ofNullable(null_) fun isMatrix(): Boolean = matrix != null fun isTier(): Boolean = tier != null - fun isOther(): Boolean = other != null + fun isNull(): Boolean = null_ != null - fun asMatrix(): MatrixSubLineItem = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asTier(): TierSubLineItem = tier.getOrThrow("tier") + fun asTier(): Tier = tier.getOrThrow("tier") - fun asOther(): OtherSubLineItem = other.getOrThrow("other") + fun asNull(): Null = null_.getOrThrow("null_") fun _json(): Optional = Optional.ofNullable(_json) @@ -11403,7 +10678,7 @@ private constructor( when { matrix != null -> visitor.visitMatrix(matrix) tier != null -> visitor.visitTier(tier) - other != null -> visitor.visitOther(other) + null_ != null -> visitor.visitNull(null_) else -> visitor.unknown(_json) } @@ -11416,16 +10691,16 @@ private constructor( accept( object : Visitor { - override fun visitMatrix(matrix: MatrixSubLineItem) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } - override fun visitTier(tier: TierSubLineItem) { + override fun visitTier(tier: Tier) { tier.validate() } - override fun visitOther(other: OtherSubLineItem) { - other.validate() + override fun visitNull(null_: Null) { + null_.validate() } } ) @@ -11450,11 +10725,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitMatrix(matrix: MatrixSubLineItem) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() - override fun visitTier(tier: TierSubLineItem) = tier.validity() + override fun visitTier(tier: Tier) = tier.validity() - override fun visitOther(other: OtherSubLineItem) = other.validity() + override fun visitNull(null_: Null) = null_.validity() override fun unknown(json: JsonValue?) = 0 } @@ -11465,27 +10740,27 @@ private constructor( return true } - return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && this.other == other.other /* spotless:on */ + return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && null_ == other.null_ /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, other) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, null_) /* spotless:on */ override fun toString(): String = when { matrix != null -> "SubLineItem{matrix=$matrix}" tier != null -> "SubLineItem{tier=$tier}" - other != null -> "SubLineItem{other=$other}" + 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 ofMatrix(matrix: Matrix) = SubLineItem(matrix = matrix) - @JvmStatic fun ofTier(tier: TierSubLineItem) = SubLineItem(tier = tier) + @JvmStatic fun ofTier(tier: Tier) = SubLineItem(tier = tier) - @JvmStatic fun ofOther(other: OtherSubLineItem) = SubLineItem(other = other) + @JvmStatic fun ofNull(null_: Null) = SubLineItem(null_ = null_) } /** @@ -11494,11 +10769,11 @@ private constructor( */ interface Visitor { - fun visitMatrix(matrix: MatrixSubLineItem): T + fun visitMatrix(matrix: Matrix): T - fun visitTier(tier: TierSubLineItem): T + fun visitTier(tier: Tier): T - fun visitOther(other: OtherSubLineItem): T + fun visitNull(null_: Null): T /** * Maps an unknown variant of [SubLineItem] to a value of type [T]. @@ -11523,18 +10798,18 @@ private constructor( when (type) { "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { SubLineItem(matrix = it, _json = json) } ?: SubLineItem(_json = json) } "tier" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { SubLineItem(tier = it, _json = json) } ?: SubLineItem(_json = json) } "'null'" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - SubLineItem(other = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(null_ = it, _json = json) } ?: SubLineItem(_json = json) } } @@ -11553,21 +10828,21 @@ private constructor( when { value.matrix != null -> generator.writeObject(value.matrix) value.tier != null -> generator.writeObject(value.tier) - value.other != null -> generator.writeObject(value.other) + value.null_ != null -> generator.writeObject(value.null_) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid SubLineItem") } } } - class MatrixSubLineItem + class Matrix private constructor( private val amount: JsonField, private val grouping: JsonField, private val matrixConfig: JsonField, private val name: JsonField, private val quantity: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -11588,7 +10863,7 @@ private constructor( @JsonProperty("quantity") @ExcludeMissing quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(amount, grouping, matrixConfig, name, quantity, type, mutableMapOf()) /** @@ -11628,11 +10903,15 @@ private constructor( fun quantity(): Double = quantity.getRequired("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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [amount]. @@ -11680,14 +10959,6 @@ private constructor( @ExcludeMissing fun _quantity(): JsonField = quantity - /** - * 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) @@ -11703,8 +10974,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MatrixSubLineItem]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java @@ -11713,13 +10983,12 @@ private constructor( * .matrixConfig() * .name() * .quantity() - * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixSubLineItem]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var amount: JsonField? = null @@ -11727,18 +10996,18 @@ private constructor( private var matrixConfig: JsonField? = null private var name: JsonField? = null private var quantity: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("matrix") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixSubLineItem: MatrixSubLineItem) = apply { - amount = matrixSubLineItem.amount - grouping = matrixSubLineItem.grouping - matrixConfig = matrixSubLineItem.matrixConfig - name = matrixSubLineItem.name - quantity = matrixSubLineItem.quantity - type = matrixSubLineItem.type - additionalProperties = matrixSubLineItem.additionalProperties.toMutableMap() + internal fun from(matrix: Matrix) = apply { + amount = matrix.amount + grouping = matrix.grouping + matrixConfig = matrix.matrixConfig + name = matrix.name + quantity = matrix.quantity + type = matrix.type + additionalProperties = matrix.additionalProperties.toMutableMap() } /** The total amount for this sub line item. */ @@ -11803,16 +11072,19 @@ private constructor( */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * 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("matrix") + * ``` * - * 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. + * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -11837,7 +11109,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixSubLineItem]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -11848,26 +11120,25 @@ private constructor( * .matrixConfig() * .name() * .quantity() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixSubLineItem = - MatrixSubLineItem( + fun build(): Matrix = + Matrix( checkRequired("amount", amount), checkRequired("grouping", grouping), checkRequired("matrixConfig", matrixConfig), checkRequired("name", name), checkRequired("quantity", quantity), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): MatrixSubLineItem = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -11877,7 +11148,11 @@ private constructor( matrixConfig().validate() name() quantity() - type().validate() + _type().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -11902,7 +11177,7 @@ 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.let { if (it == JsonValue.from("matrix")) 1 else 0 } class Grouping private constructor( @@ -12303,139 +11578,12 @@ private constructor( "MatrixConfig{dimensionValues=$dimensionValues, additionalProperties=$additionalProperties}" } - 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 MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is 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 /* spotless:off */ other is Matrix && amount == other.amount && grouping == other.grouping && matrixConfig == other.matrixConfig && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -12445,17 +11593,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixSubLineItem{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" + "Matrix{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" } - class TierSubLineItem + class Tier private constructor( private val amount: JsonField, private val grouping: JsonField, private val name: JsonField, private val quantity: JsonField, private val tierConfig: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -12476,7 +11624,7 @@ private constructor( @JsonProperty("tier_config") @ExcludeMissing tierConfig: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(amount, grouping, name, quantity, tierConfig, type, mutableMapOf()) /** @@ -12516,11 +11664,15 @@ private constructor( fun tierConfig(): TierConfig = tierConfig.getRequired("tier_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). + * Expected to always return the following: + * ```java + * JsonValue.from("tier") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [amount]. @@ -12568,14 +11720,6 @@ private constructor( @ExcludeMissing fun _tierConfig(): JsonField = tierConfig - /** - * 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) @@ -12591,7 +11735,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TierSubLineItem]. + * Returns a mutable builder for constructing an instance of [Tier]. * * The following fields are required: * ```java @@ -12600,13 +11744,12 @@ private constructor( * .name() * .quantity() * .tierConfig() - * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TierSubLineItem]. */ + /** A builder for [Tier]. */ class Builder internal constructor() { private var amount: JsonField? = null @@ -12614,18 +11757,18 @@ private constructor( private var name: JsonField? = null private var quantity: JsonField? = null private var tierConfig: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("tier") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tierSubLineItem: TierSubLineItem) = apply { - amount = tierSubLineItem.amount - grouping = tierSubLineItem.grouping - name = tierSubLineItem.name - quantity = tierSubLineItem.quantity - tierConfig = tierSubLineItem.tierConfig - type = tierSubLineItem.type - additionalProperties = tierSubLineItem.additionalProperties.toMutableMap() + internal fun from(tier: Tier) = apply { + amount = tier.amount + grouping = tier.grouping + name = tier.name + quantity = tier.quantity + tierConfig = tier.tierConfig + type = tier.type + additionalProperties = tier.additionalProperties.toMutableMap() } /** The total amount for this sub line item. */ @@ -12689,16 +11832,19 @@ private constructor( this.tierConfig = tierConfig } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tier") + * ``` + * + * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -12723,7 +11869,7 @@ private constructor( } /** - * Returns an immutable instance of [TierSubLineItem]. + * Returns an immutable instance of [Tier]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -12734,26 +11880,25 @@ private constructor( * .name() * .quantity() * .tierConfig() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TierSubLineItem = - TierSubLineItem( + fun build(): Tier = + Tier( checkRequired("amount", amount), checkRequired("grouping", grouping), checkRequired("name", name), checkRequired("quantity", quantity), checkRequired("tierConfig", tierConfig), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TierSubLineItem = apply { + fun validate(): Tier = apply { if (validated) { return@apply } @@ -12763,7 +11908,11 @@ private constructor( name() quantity() tierConfig().validate() - type().validate() + _type().let { + if (it != JsonValue.from("tier")) { + throw OrbInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -12788,7 +11937,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + (tierConfig.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("tier")) 1 else 0 } class Grouping private constructor( @@ -13257,139 +12406,12 @@ private constructor( "TierConfig{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - 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 TIER = of("tier") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TIER - } - - /** - * 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 { - TIER, - /** - * 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) { - TIER -> Value.TIER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIER -> Known.TIER - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is 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 /* spotless:off */ other is Tier && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && tierConfig == other.tierConfig && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -13399,16 +12421,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TierSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, tierConfig=$tierConfig, type=$type, additionalProperties=$additionalProperties}" + "Tier{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, tierConfig=$tierConfig, type=$type, additionalProperties=$additionalProperties}" } - class OtherSubLineItem + class Null private constructor( private val amount: JsonField, private val grouping: JsonField, private val name: JsonField, private val quantity: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -13426,7 +12448,7 @@ private constructor( @JsonProperty("quantity") @ExcludeMissing quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(amount, grouping, name, quantity, type, mutableMapOf()) /** @@ -13459,11 +12481,15 @@ private constructor( fun quantity(): Double = quantity.getRequired("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). + * Expected to always return the following: + * ```java + * JsonValue.from("'null'") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [amount]. @@ -13501,14 +12527,6 @@ private constructor( @ExcludeMissing fun _quantity(): JsonField = quantity - /** - * 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) @@ -13524,7 +12542,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [OtherSubLineItem]. + * Returns a mutable builder for constructing an instance of [Null]. * * The following fields are required: * ```java @@ -13532,30 +12550,29 @@ private constructor( * .grouping() * .name() * .quantity() - * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [OtherSubLineItem]. */ + /** A builder for [Null]. */ class Builder internal constructor() { private var amount: JsonField? = null private var grouping: JsonField? = null private var name: JsonField? = null private var quantity: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("'null'") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(otherSubLineItem: OtherSubLineItem) = apply { - amount = otherSubLineItem.amount - grouping = otherSubLineItem.grouping - name = otherSubLineItem.name - quantity = otherSubLineItem.quantity - type = otherSubLineItem.type - additionalProperties = otherSubLineItem.additionalProperties.toMutableMap() + internal fun from(null_: Null) = apply { + amount = null_.amount + grouping = null_.grouping + name = null_.name + quantity = null_.quantity + type = null_.type + additionalProperties = null_.additionalProperties.toMutableMap() } /** The total amount for this sub line item. */ @@ -13606,16 +12623,19 @@ private constructor( */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("'null'") + * ``` + * + * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -13640,7 +12660,7 @@ private constructor( } /** - * Returns an immutable instance of [OtherSubLineItem]. + * Returns an immutable instance of [Null]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -13650,25 +12670,24 @@ private constructor( * .grouping() * .name() * .quantity() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): OtherSubLineItem = - OtherSubLineItem( + fun build(): Null = + Null( checkRequired("amount", amount), checkRequired("grouping", grouping), checkRequired("name", name), checkRequired("quantity", quantity), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): OtherSubLineItem = apply { + fun validate(): Null = apply { if (validated) { return@apply } @@ -13677,7 +12696,11 @@ private constructor( grouping().ifPresent { it.validate() } name() quantity() - type().validate() + _type().let { + if (it != JsonValue.from("'null'")) { + throw OrbInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -13701,7 +12724,7 @@ private constructor( (grouping.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("'null'")) 1 else 0 } class Grouping private constructor( @@ -13910,139 +12933,12 @@ private constructor( "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" } - 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 NULL = of("'null'") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - NULL - } - - /** - * 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 { - NULL, - /** - * 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) { - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - NULL -> Known.NULL - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is OtherSubLineItem && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Null && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -14052,7 +12948,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OtherSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" + "Null{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" } } 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 4b982d83..5bbf2121 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 @@ -11,13 +11,13 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint allows an eligible invoice to be issued manually. This is only possible with @@ -28,13 +28,13 @@ import java.util.Optional */ class InvoiceIssueParams private constructor( - private val invoiceId: String, + private val invoiceId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun invoiceId(): String = invoiceId + fun invoiceId(): Optional = Optional.ofNullable(invoiceId) /** * If true, the invoice will be issued synchronously. If false, the invoice will be issued @@ -64,14 +64,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [InvoiceIssueParams]. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - */ + @JvmStatic fun none(): InvoiceIssueParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InvoiceIssueParams]. */ @JvmStatic fun builder() = Builder() } @@ -91,7 +86,10 @@ private constructor( additionalQueryParams = invoiceIssueParams.additionalQueryParams.toBuilder() } - fun invoiceId(invoiceId: String) = apply { this.invoiceId = invoiceId } + fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } + + /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.getOrNull()) /** * Sets the entire request body. @@ -240,17 +238,10 @@ private constructor( * Returns an immutable instance of [InvoiceIssueParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): InvoiceIssueParams = InvoiceIssueParams( - checkRequired("invoiceId", invoiceId), + invoiceId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -261,7 +252,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> invoiceId + 0 -> invoiceId ?: "" else -> "" } 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 5d8baa87..f90c5e0c 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 @@ -15,7 +15,6 @@ 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 @@ -670,39 +669,28 @@ private constructor( } } - /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryUsageDiscount(monetaryUsageDiscount)`. - */ - fun addAdjustment(monetaryUsageDiscount: Adjustment.MonetaryUsageDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryUsageDiscount(monetaryUsageDiscount)) + /** Alias for calling [addAdjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun addAdjustment(usageDiscount: Adjustment.UsageDiscount) = + addAdjustment(Adjustment.ofUsageDiscount(usageDiscount)) - /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryAmountDiscount(monetaryAmountDiscount)`. - */ - fun addAdjustment(monetaryAmountDiscount: Adjustment.MonetaryAmountDiscountAdjustment) = - addAdjustment(Adjustment.ofMonetaryAmountDiscount(monetaryAmountDiscount)) + /** Alias for calling [addAdjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ + fun addAdjustment(amountDiscount: Adjustment.AmountDiscount) = + addAdjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [addAdjustment] with - * `Adjustment.ofMonetaryPercentageDiscount(monetaryPercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun addAdjustment( - monetaryPercentageDiscount: Adjustment.MonetaryPercentageDiscountAdjustment - ) = addAdjustment(Adjustment.ofMonetaryPercentageDiscount(monetaryPercentageDiscount)) + fun addAdjustment(percentageDiscount: Adjustment.PercentageDiscount) = + addAdjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [addAdjustment] with `Adjustment.ofMonetaryMinimum(monetaryMinimum)`. - */ - fun addAdjustment(monetaryMinimum: Adjustment.MonetaryMinimumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMinimum(monetaryMinimum)) + /** Alias for calling [addAdjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun addAdjustment(minimum: Adjustment.Minimum) = + addAdjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [addAdjustment] with `Adjustment.ofMonetaryMaximum(monetaryMaximum)`. - */ - fun addAdjustment(monetaryMaximum: Adjustment.MonetaryMaximumAdjustment) = - addAdjustment(Adjustment.ofMonetaryMaximum(monetaryMaximum)) + /** Alias for calling [addAdjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun addAdjustment(maximum: Adjustment.Maximum) = + addAdjustment(Adjustment.ofMaximum(maximum)) /** * The final amount for a line item after all adjustments and pre paid credits have been @@ -949,130 +937,128 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = - price(Price.ofTieredPackage(tieredPackage)) + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = - price(Price.ofGroupedTiered(groupedTiered)) + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** Either the fixed fee quantity or the usage during the service period. */ @@ -1128,16 +1114,14 @@ private constructor( } /** Alias for calling [addSubLineItem] with `SubLineItem.ofMatrix(matrix)`. */ - fun addSubLineItem(matrix: SubLineItem.MatrixSubLineItem) = + fun addSubLineItem(matrix: SubLineItem.Matrix) = addSubLineItem(SubLineItem.ofMatrix(matrix)) /** Alias for calling [addSubLineItem] with `SubLineItem.ofTier(tier)`. */ - fun addSubLineItem(tier: SubLineItem.TierSubLineItem) = - addSubLineItem(SubLineItem.ofTier(tier)) + fun addSubLineItem(tier: SubLineItem.Tier) = addSubLineItem(SubLineItem.ofTier(tier)) - /** Alias for calling [addSubLineItem] with `SubLineItem.ofOther(other)`. */ - fun addSubLineItem(other: SubLineItem.OtherSubLineItem) = - addSubLineItem(SubLineItem.ofOther(other)) + /** Alias for calling [addSubLineItem] with `SubLineItem.ofNull(null_)`. */ + fun addSubLineItem(null_: SubLineItem.Null) = addSubLineItem(SubLineItem.ofNull(null_)) /** The line amount before before any adjustments. */ fun subtotal(subtotal: String) = subtotal(JsonField.of(subtotal)) @@ -1364,66 +1348,55 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val monetaryUsageDiscount: MonetaryUsageDiscountAdjustment? = null, - private val monetaryAmountDiscount: MonetaryAmountDiscountAdjustment? = null, - private val monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment? = null, - private val monetaryMinimum: MonetaryMinimumAdjustment? = null, - private val monetaryMaximum: MonetaryMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun monetaryUsageDiscount(): Optional = - Optional.ofNullable(monetaryUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun monetaryAmountDiscount(): Optional = - Optional.ofNullable(monetaryAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun monetaryPercentageDiscount(): Optional = - Optional.ofNullable(monetaryPercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun monetaryMinimum(): Optional = - Optional.ofNullable(monetaryMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun monetaryMaximum(): Optional = - Optional.ofNullable(monetaryMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isMonetaryUsageDiscount(): Boolean = monetaryUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isMonetaryAmountDiscount(): Boolean = monetaryAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isMonetaryPercentageDiscount(): Boolean = monetaryPercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isMonetaryMinimum(): Boolean = monetaryMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isMonetaryMaximum(): Boolean = monetaryMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asMonetaryUsageDiscount(): MonetaryUsageDiscountAdjustment = - monetaryUsageDiscount.getOrThrow("monetaryUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asMonetaryAmountDiscount(): MonetaryAmountDiscountAdjustment = - monetaryAmountDiscount.getOrThrow("monetaryAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asMonetaryPercentageDiscount(): MonetaryPercentageDiscountAdjustment = - monetaryPercentageDiscount.getOrThrow("monetaryPercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asMonetaryMinimum(): MonetaryMinimumAdjustment = - monetaryMinimum.getOrThrow("monetaryMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asMonetaryMaximum(): MonetaryMaximumAdjustment = - monetaryMaximum.getOrThrow("monetaryMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - monetaryUsageDiscount != null -> - visitor.visitMonetaryUsageDiscount(monetaryUsageDiscount) - monetaryAmountDiscount != null -> - visitor.visitMonetaryAmountDiscount(monetaryAmountDiscount) - monetaryPercentageDiscount != null -> - visitor.visitMonetaryPercentageDiscount(monetaryPercentageDiscount) - monetaryMinimum != null -> visitor.visitMonetaryMinimum(monetaryMinimum) - monetaryMaximum != null -> visitor.visitMonetaryMaximum(monetaryMaximum) + 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) } @@ -1436,30 +1409,24 @@ private constructor( accept( object : Visitor { - override fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) { - monetaryUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) { - monetaryAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) { - monetaryPercentageDiscount.validate() + override fun visitPercentageDiscount(percentageDiscount: PercentageDiscount) { + percentageDiscount.validate() } - override fun visitMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment) { - monetaryMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment) { - monetaryMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -1484,23 +1451,18 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ) = monetaryUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ) = monetaryAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) = monetaryPercentageDiscount.validity() + override fun visitPercentageDiscount(percentageDiscount: PercentageDiscount) = + percentageDiscount.validity() - override fun visitMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment) = - monetaryMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment) = - monetaryMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1511,21 +1473,18 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && monetaryUsageDiscount == other.monetaryUsageDiscount && monetaryAmountDiscount == other.monetaryAmountDiscount && monetaryPercentageDiscount == other.monetaryPercentageDiscount && monetaryMinimum == other.monetaryMinimum && monetaryMaximum == other.monetaryMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(monetaryUsageDiscount, monetaryAmountDiscount, monetaryPercentageDiscount, monetaryMinimum, monetaryMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - monetaryUsageDiscount != null -> - "Adjustment{monetaryUsageDiscount=$monetaryUsageDiscount}" - monetaryAmountDiscount != null -> - "Adjustment{monetaryAmountDiscount=$monetaryAmountDiscount}" - monetaryPercentageDiscount != null -> - "Adjustment{monetaryPercentageDiscount=$monetaryPercentageDiscount}" - monetaryMinimum != null -> "Adjustment{monetaryMinimum=$monetaryMinimum}" - monetaryMaximum != null -> "Adjustment{monetaryMaximum=$monetaryMaximum}" + 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") } @@ -1533,25 +1492,20 @@ private constructor( companion object { @JvmStatic - fun ofMonetaryUsageDiscount(monetaryUsageDiscount: MonetaryUsageDiscountAdjustment) = - Adjustment(monetaryUsageDiscount = monetaryUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofMonetaryAmountDiscount(monetaryAmountDiscount: MonetaryAmountDiscountAdjustment) = - Adjustment(monetaryAmountDiscount = monetaryAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ) = Adjustment(monetaryPercentageDiscount = monetaryPercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment) = - Adjustment(monetaryMinimum = monetaryMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment) = - Adjustment(monetaryMaximum = monetaryMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -1559,21 +1513,15 @@ private constructor( */ interface Visitor { - fun visitMonetaryUsageDiscount( - monetaryUsageDiscount: MonetaryUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitMonetaryAmountDiscount( - monetaryAmountDiscount: MonetaryAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitMonetaryPercentageDiscount( - monetaryPercentageDiscount: MonetaryPercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitMonetaryMinimum(monetaryMinimum: MonetaryMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitMonetaryMaximum(monetaryMaximum: MonetaryMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -1599,38 +1547,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(monetaryUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(monetaryAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(monetaryPercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(monetaryMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(monetaryMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -1646,24 +1585,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.monetaryUsageDiscount != null -> - generator.writeObject(value.monetaryUsageDiscount) - value.monetaryAmountDiscount != null -> - generator.writeObject(value.monetaryAmountDiscount) - value.monetaryPercentageDiscount != null -> - generator.writeObject(value.monetaryPercentageDiscount) - value.monetaryMinimum != null -> generator.writeObject(value.monetaryMinimum) - value.monetaryMaximum != null -> generator.writeObject(value.monetaryMaximum) + 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") } } } - class MonetaryUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -1677,7 +1614,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -1712,11 +1649,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -1772,16 +1715,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -1841,13 +1774,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -1858,11 +1789,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -1871,19 +1802,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - monetaryUsageDiscountAdjustment: MonetaryUsageDiscountAdjustment - ) = apply { - id = monetaryUsageDiscountAdjustment.id - adjustmentType = monetaryUsageDiscountAdjustment.adjustmentType - amount = monetaryUsageDiscountAdjustment.amount - appliesToPriceIds = - monetaryUsageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = monetaryUsageDiscountAdjustment.isInvoiceLevel - reason = monetaryUsageDiscountAdjustment.reason - usageDiscount = monetaryUsageDiscountAdjustment.usageDiscount - additionalProperties = - monetaryUsageDiscountAdjustment.additionalProperties.toMutableMap() + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType + amount = usageDiscount.amount + appliesToPriceIds = usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -1897,17 +1824,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2024,14 +1953,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -2041,10 +1969,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryUsageDiscountAdjustment = - MonetaryUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -2058,13 +1986,17 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -2090,147 +2022,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("usage_discount")) 1 else 0 } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2240,13 +2044,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class MonetaryAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, @@ -2260,7 +2064,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -2293,11 +2097,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -2353,16 +2163,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -2422,13 +2222,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .amountDiscount() * .appliesToPriceIds() @@ -2439,11 +2237,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amount: JsonField? = null private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null @@ -2452,21 +2250,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - monetaryAmountDiscountAdjustment: MonetaryAmountDiscountAdjustment - ) = apply { - id = monetaryAmountDiscountAdjustment.id - adjustmentType = monetaryAmountDiscountAdjustment.adjustmentType - amount = monetaryAmountDiscountAdjustment.amount - amountDiscount = monetaryAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - monetaryAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryAmountDiscountAdjustment.isInvoiceLevel - reason = monetaryAmountDiscountAdjustment.reason - additionalProperties = - monetaryAmountDiscountAdjustment.additionalProperties.toMutableMap() + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + amount = amountDiscount.amount + this.amountDiscount = amountDiscount.amountDiscount + appliesToPriceIds = amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2480,17 +2272,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2607,14 +2401,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .amountDiscount() * .appliesToPriceIds() @@ -2624,10 +2417,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryAmountDiscountAdjustment = - MonetaryAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { @@ -2641,13 +2434,17 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } amount() amountDiscount() appliesToPriceIds() @@ -2673,147 +2470,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("amount_discount")) 1 else 0 } + (if (amount.asKnown().isPresent) 1 else 0) + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2823,13 +2492,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amount=$amount, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, reason=$reason, additionalProperties=$additionalProperties}" } - class MonetaryPercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2843,7 +2512,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -2876,11 +2545,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -2936,16 +2611,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -3005,13 +2670,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryPercentageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3022,11 +2685,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryPercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3035,21 +2698,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - monetaryPercentageDiscountAdjustment: MonetaryPercentageDiscountAdjustment - ) = apply { - id = monetaryPercentageDiscountAdjustment.id - adjustmentType = monetaryPercentageDiscountAdjustment.adjustmentType - amount = monetaryPercentageDiscountAdjustment.amount + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType + amount = percentageDiscount.amount appliesToPriceIds = - monetaryPercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = monetaryPercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = monetaryPercentageDiscountAdjustment.percentageDiscount - reason = monetaryPercentageDiscountAdjustment.reason - additionalProperties = - monetaryPercentageDiscountAdjustment.additionalProperties.toMutableMap() + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + reason = percentageDiscount.reason + additionalProperties = percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3063,17 +2721,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3190,14 +2850,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryPercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3207,10 +2866,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryPercentageDiscountAdjustment = - MonetaryPercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3224,13 +2883,17 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryPercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -3256,163 +2919,37 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val PERCENTAGE_DISCOUNT = of("percentage_discount") + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + } - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, percentageDiscount, reason, additionalProperties) } + /* spotless:on */ - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } + override fun hashCode(): Int = hashCode - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + override fun toString() = + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, reason=$reason, 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) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is MonetaryPercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, adjustmentType, amount, appliesToPriceIds, isInvoiceLevel, percentageDiscount, reason, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MonetaryPercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, reason=$reason, additionalProperties=$additionalProperties}" - } - - class MonetaryMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -3427,7 +2964,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -3464,11 +3001,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -3533,16 +3076,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -3609,13 +3142,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3627,11 +3158,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3641,18 +3172,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(monetaryMinimumAdjustment: MonetaryMinimumAdjustment) = apply { - id = monetaryMinimumAdjustment.id - adjustmentType = monetaryMinimumAdjustment.adjustmentType - amount = monetaryMinimumAdjustment.amount - appliesToPriceIds = - monetaryMinimumAdjustment.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = monetaryMinimumAdjustment.isInvoiceLevel - itemId = monetaryMinimumAdjustment.itemId - minimumAmount = monetaryMinimumAdjustment.minimumAmount - reason = monetaryMinimumAdjustment.reason - additionalProperties = - monetaryMinimumAdjustment.additionalProperties.toMutableMap() + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + amount = minimum.amount + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3666,17 +3195,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3805,14 +3336,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3823,10 +3353,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryMinimumAdjustment = - MonetaryMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3841,13 +3371,17 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -3874,7 +3408,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + @@ -3882,140 +3416,12 @@ private constructor( (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4025,13 +3431,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, reason=$reason, additionalProperties=$additionalProperties}" } - class MonetaryMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -4045,7 +3451,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), @@ -4078,11 +3484,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The value applied by an adjustment. @@ -4138,16 +3550,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amount]. * @@ -4207,13 +3609,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MonetaryMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -4224,11 +3624,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MonetaryMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var amount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -4237,17 +3637,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(monetaryMaximumAdjustment: MonetaryMaximumAdjustment) = apply { - id = monetaryMaximumAdjustment.id - adjustmentType = monetaryMaximumAdjustment.adjustmentType - amount = monetaryMaximumAdjustment.amount - appliesToPriceIds = - monetaryMaximumAdjustment.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = monetaryMaximumAdjustment.isInvoiceLevel - maximumAmount = monetaryMaximumAdjustment.maximumAmount - reason = monetaryMaximumAdjustment.reason - additionalProperties = - monetaryMaximumAdjustment.additionalProperties.toMutableMap() + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + amount = maximum.amount + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -4261,17 +3659,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4388,14 +3788,13 @@ private constructor( } /** - * Returns an immutable instance of [MonetaryMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -4405,10 +3804,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MonetaryMaximumAdjustment = - MonetaryMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amount", amount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -4422,13 +3821,17 @@ private constructor( private var validated: Boolean = false - fun validate(): MonetaryMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } amount() appliesToPriceIds() isInvoiceLevel() @@ -4454,147 +3857,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (if (amount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MonetaryMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && amount == other.amount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4604,7 +3879,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MonetaryMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, amount=$amount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5072,29 +4347,29 @@ private constructor( @JsonSerialize(using = SubLineItem.Serializer::class) class SubLineItem private constructor( - private val matrix: MatrixSubLineItem? = null, - private val tier: TierSubLineItem? = null, - private val other: OtherSubLineItem? = null, + private val matrix: Matrix? = null, + private val tier: Tier? = null, + private val null_: Null? = null, private val _json: JsonValue? = null, ) { - fun matrix(): Optional = Optional.ofNullable(matrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun tier(): Optional = Optional.ofNullable(tier) + fun tier(): Optional = Optional.ofNullable(tier) - fun other(): Optional = Optional.ofNullable(other) + fun null_(): Optional = Optional.ofNullable(null_) fun isMatrix(): Boolean = matrix != null fun isTier(): Boolean = tier != null - fun isOther(): Boolean = other != null + fun isNull(): Boolean = null_ != null - fun asMatrix(): MatrixSubLineItem = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asTier(): TierSubLineItem = tier.getOrThrow("tier") + fun asTier(): Tier = tier.getOrThrow("tier") - fun asOther(): OtherSubLineItem = other.getOrThrow("other") + fun asNull(): Null = null_.getOrThrow("null_") fun _json(): Optional = Optional.ofNullable(_json) @@ -5102,7 +4377,7 @@ private constructor( when { matrix != null -> visitor.visitMatrix(matrix) tier != null -> visitor.visitTier(tier) - other != null -> visitor.visitOther(other) + null_ != null -> visitor.visitNull(null_) else -> visitor.unknown(_json) } @@ -5115,16 +4390,16 @@ private constructor( accept( object : Visitor { - override fun visitMatrix(matrix: MatrixSubLineItem) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } - override fun visitTier(tier: TierSubLineItem) { + override fun visitTier(tier: Tier) { tier.validate() } - override fun visitOther(other: OtherSubLineItem) { - other.validate() + override fun visitNull(null_: Null) { + null_.validate() } } ) @@ -5149,11 +4424,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitMatrix(matrix: MatrixSubLineItem) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() - override fun visitTier(tier: TierSubLineItem) = tier.validity() + override fun visitTier(tier: Tier) = tier.validity() - override fun visitOther(other: OtherSubLineItem) = other.validity() + override fun visitNull(null_: Null) = null_.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5164,27 +4439,27 @@ private constructor( return true } - return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && this.other == other.other /* spotless:on */ + return /* spotless:off */ other is SubLineItem && matrix == other.matrix && tier == other.tier && null_ == other.null_ /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, other) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(matrix, tier, null_) /* spotless:on */ override fun toString(): String = when { matrix != null -> "SubLineItem{matrix=$matrix}" tier != null -> "SubLineItem{tier=$tier}" - other != null -> "SubLineItem{other=$other}" + 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 ofMatrix(matrix: Matrix) = SubLineItem(matrix = matrix) - @JvmStatic fun ofTier(tier: TierSubLineItem) = SubLineItem(tier = tier) + @JvmStatic fun ofTier(tier: Tier) = SubLineItem(tier = tier) - @JvmStatic fun ofOther(other: OtherSubLineItem) = SubLineItem(other = other) + @JvmStatic fun ofNull(null_: Null) = SubLineItem(null_ = null_) } /** @@ -5193,11 +4468,11 @@ private constructor( */ interface Visitor { - fun visitMatrix(matrix: MatrixSubLineItem): T + fun visitMatrix(matrix: Matrix): T - fun visitTier(tier: TierSubLineItem): T + fun visitTier(tier: Tier): T - fun visitOther(other: OtherSubLineItem): T + fun visitNull(null_: Null): T /** * Maps an unknown variant of [SubLineItem] to a value of type [T]. @@ -5222,18 +4497,18 @@ private constructor( when (type) { "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { SubLineItem(matrix = it, _json = json) } ?: SubLineItem(_json = json) } "tier" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { SubLineItem(tier = it, _json = json) } ?: SubLineItem(_json = json) } "'null'" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - SubLineItem(other = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + SubLineItem(null_ = it, _json = json) } ?: SubLineItem(_json = json) } } @@ -5252,21 +4527,21 @@ private constructor( when { value.matrix != null -> generator.writeObject(value.matrix) value.tier != null -> generator.writeObject(value.tier) - value.other != null -> generator.writeObject(value.other) + value.null_ != null -> generator.writeObject(value.null_) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid SubLineItem") } } } - class MatrixSubLineItem + class Matrix private constructor( private val amount: JsonField, private val grouping: JsonField, private val matrixConfig: JsonField, private val name: JsonField, private val quantity: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -5285,7 +4560,7 @@ private constructor( @JsonProperty("quantity") @ExcludeMissing quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(amount, grouping, matrixConfig, name, quantity, type, mutableMapOf()) /** @@ -5324,12 +4599,16 @@ private constructor( */ fun quantity(): Double = quantity.getRequired("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). + /** + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [amount]. @@ -5373,13 +4652,6 @@ private constructor( */ @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - /** - * 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) @@ -5395,7 +4667,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MatrixSubLineItem]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java @@ -5404,13 +4676,12 @@ private constructor( * .matrixConfig() * .name() * .quantity() - * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixSubLineItem]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var amount: JsonField? = null @@ -5418,18 +4689,18 @@ private constructor( private var matrixConfig: JsonField? = null private var name: JsonField? = null private var quantity: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("matrix") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixSubLineItem: MatrixSubLineItem) = apply { - amount = matrixSubLineItem.amount - grouping = matrixSubLineItem.grouping - matrixConfig = matrixSubLineItem.matrixConfig - name = matrixSubLineItem.name - quantity = matrixSubLineItem.quantity - type = matrixSubLineItem.type - additionalProperties = matrixSubLineItem.additionalProperties.toMutableMap() + internal fun from(matrix: Matrix) = apply { + amount = matrix.amount + grouping = matrix.grouping + matrixConfig = matrix.matrixConfig + name = matrix.name + quantity = matrix.quantity + type = matrix.type + additionalProperties = matrix.additionalProperties.toMutableMap() } /** The total amount for this sub line item. */ @@ -5494,16 +4765,19 @@ private constructor( */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * 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("matrix") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -5528,7 +4802,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixSubLineItem]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -5539,26 +4813,25 @@ private constructor( * .matrixConfig() * .name() * .quantity() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixSubLineItem = - MatrixSubLineItem( + fun build(): Matrix = + Matrix( checkRequired("amount", amount), checkRequired("grouping", grouping), checkRequired("matrixConfig", matrixConfig), checkRequired("name", name), checkRequired("quantity", quantity), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): MatrixSubLineItem = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -5568,7 +4841,11 @@ private constructor( matrixConfig().validate() name() quantity() - type().validate() + _type().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -5593,7 +4870,7 @@ 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.let { if (it == JsonValue.from("matrix")) 1 else 0 } class Grouping private constructor( @@ -5987,136 +5264,12 @@ private constructor( "MatrixConfig{dimensionValues=$dimensionValues, additionalProperties=$additionalProperties}" } - 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 MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is 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 /* spotless:off */ other is Matrix && amount == other.amount && grouping == other.grouping && matrixConfig == other.matrixConfig && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6126,17 +5279,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixSubLineItem{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" + "Matrix{amount=$amount, grouping=$grouping, matrixConfig=$matrixConfig, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" } - class TierSubLineItem + class Tier private constructor( private val amount: JsonField, private val grouping: JsonField, private val name: JsonField, private val quantity: JsonField, private val tierConfig: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -6155,7 +5308,7 @@ private constructor( @JsonProperty("tier_config") @ExcludeMissing tierConfig: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(amount, grouping, name, quantity, tierConfig, type, mutableMapOf()) /** @@ -6195,11 +5348,15 @@ private constructor( fun tierConfig(): TierConfig = tierConfig.getRequired("tier_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). + * Expected to always return the following: + * ```java + * JsonValue.from("tier") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [amount]. @@ -6243,13 +5400,6 @@ private constructor( @ExcludeMissing fun _tierConfig(): JsonField = tierConfig - /** - * 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) @@ -6265,7 +5415,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TierSubLineItem]. + * Returns a mutable builder for constructing an instance of [Tier]. * * The following fields are required: * ```java @@ -6274,13 +5424,12 @@ private constructor( * .name() * .quantity() * .tierConfig() - * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TierSubLineItem]. */ + /** A builder for [Tier]. */ class Builder internal constructor() { private var amount: JsonField? = null @@ -6288,18 +5437,18 @@ private constructor( private var name: JsonField? = null private var quantity: JsonField? = null private var tierConfig: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("tier") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tierSubLineItem: TierSubLineItem) = apply { - amount = tierSubLineItem.amount - grouping = tierSubLineItem.grouping - name = tierSubLineItem.name - quantity = tierSubLineItem.quantity - tierConfig = tierSubLineItem.tierConfig - type = tierSubLineItem.type - additionalProperties = tierSubLineItem.additionalProperties.toMutableMap() + internal fun from(tier: Tier) = apply { + amount = tier.amount + grouping = tier.grouping + name = tier.name + quantity = tier.quantity + tierConfig = tier.tierConfig + type = tier.type + additionalProperties = tier.additionalProperties.toMutableMap() } /** The total amount for this sub line item. */ @@ -6363,16 +5512,19 @@ private constructor( this.tierConfig = tierConfig } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * 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("tier") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -6397,7 +5549,7 @@ private constructor( } /** - * Returns an immutable instance of [TierSubLineItem]. + * Returns an immutable instance of [Tier]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6408,26 +5560,25 @@ private constructor( * .name() * .quantity() * .tierConfig() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): TierSubLineItem = - TierSubLineItem( + fun build(): Tier = + Tier( checkRequired("amount", amount), checkRequired("grouping", grouping), checkRequired("name", name), checkRequired("quantity", quantity), checkRequired("tierConfig", tierConfig), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): TierSubLineItem = apply { + fun validate(): Tier = apply { if (validated) { return@apply } @@ -6437,7 +5588,11 @@ private constructor( name() quantity() tierConfig().validate() - type().validate() + _type().let { + if (it != JsonValue.from("tier")) { + throw OrbInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -6462,7 +5617,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + (tierConfig.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("tier")) 1 else 0 } class Grouping private constructor( @@ -6924,136 +6079,12 @@ private constructor( "TierConfig{firstUnit=$firstUnit, lastUnit=$lastUnit, unitAmount=$unitAmount, additionalProperties=$additionalProperties}" } - 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 TIER = of("tier") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TIER - } - - /** - * 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 { - TIER, - /** - * 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) { - TIER -> Value.TIER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIER -> Known.TIER - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is 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 /* spotless:off */ other is Tier && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && tierConfig == other.tierConfig && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7063,16 +6094,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TierSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, tierConfig=$tierConfig, type=$type, additionalProperties=$additionalProperties}" + "Tier{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, tierConfig=$tierConfig, type=$type, additionalProperties=$additionalProperties}" } - class OtherSubLineItem + class Null private constructor( private val amount: JsonField, private val grouping: JsonField, private val name: JsonField, private val quantity: JsonField, - private val type: JsonField, + private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -7088,7 +6119,7 @@ private constructor( @JsonProperty("quantity") @ExcludeMissing quantity: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this(amount, grouping, name, quantity, type, mutableMapOf()) /** @@ -7121,11 +6152,15 @@ private constructor( fun quantity(): Double = quantity.getRequired("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). + * Expected to always return the following: + * ```java + * JsonValue.from("'null'") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun type(): Type = type.getRequired("type") + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type /** * Returns the raw JSON value of [amount]. @@ -7159,13 +6194,6 @@ private constructor( */ @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - /** - * 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) @@ -7181,7 +6209,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [OtherSubLineItem]. + * Returns a mutable builder for constructing an instance of [Null]. * * The following fields are required: * ```java @@ -7189,30 +6217,29 @@ private constructor( * .grouping() * .name() * .quantity() - * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [OtherSubLineItem]. */ + /** A builder for [Null]. */ class Builder internal constructor() { private var amount: JsonField? = null private var grouping: JsonField? = null private var name: JsonField? = null private var quantity: JsonField? = null - private var type: JsonField? = null + private var type: JsonValue = JsonValue.from("'null'") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(otherSubLineItem: OtherSubLineItem) = apply { - amount = otherSubLineItem.amount - grouping = otherSubLineItem.grouping - name = otherSubLineItem.name - quantity = otherSubLineItem.quantity - type = otherSubLineItem.type - additionalProperties = otherSubLineItem.additionalProperties.toMutableMap() + internal fun from(null_: Null) = apply { + amount = null_.amount + grouping = null_.grouping + name = null_.name + quantity = null_.quantity + type = null_.type + additionalProperties = null_.additionalProperties.toMutableMap() } /** The total amount for this sub line item. */ @@ -7263,16 +6290,19 @@ private constructor( */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - fun type(type: Type) = type(JsonField.of(type)) - /** - * Sets [Builder.type] to an arbitrary JSON value. + * 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("'null'") + * ``` * - * 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 type(type: JsonValue) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -7297,7 +6327,7 @@ private constructor( } /** - * Returns an immutable instance of [OtherSubLineItem]. + * Returns an immutable instance of [Null]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7307,25 +6337,24 @@ private constructor( * .grouping() * .name() * .quantity() - * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): OtherSubLineItem = - OtherSubLineItem( + fun build(): Null = + Null( checkRequired("amount", amount), checkRequired("grouping", grouping), checkRequired("name", name), checkRequired("quantity", quantity), - checkRequired("type", type), + type, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): OtherSubLineItem = apply { + fun validate(): Null = apply { if (validated) { return@apply } @@ -7334,7 +6363,11 @@ private constructor( grouping().ifPresent { it.validate() } name() quantity() - type().validate() + _type().let { + if (it != JsonValue.from("'null'")) { + throw OrbInvalidDataException("'type' is invalid, received $it") + } + } validated = true } @@ -7358,7 +6391,7 @@ private constructor( (grouping.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("'null'")) 1 else 0 } class Grouping private constructor( @@ -7563,136 +6596,12 @@ private constructor( "Grouping{key=$key, value=$value, additionalProperties=$additionalProperties}" } - 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 NULL = of("'null'") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - NULL - } - - /** - * 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 { - NULL, - /** - * 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) { - NULL -> Value.NULL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - NULL -> Known.NULL - 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 /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is OtherSubLineItem && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Null && amount == other.amount && grouping == other.grouping && name == other.name && quantity == other.quantity && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7702,7 +6611,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OtherSubLineItem{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" + "Null{amount=$amount, grouping=$grouping, name=$name, quantity=$quantity, type=$type, additionalProperties=$additionalProperties}" } } 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 6584cb93..3eb2ae02 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.InvoiceService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [InvoiceService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: InvoiceService, private val params: InvoiceListParams, private val response: InvoiceListPageResponse, -) { +) : Page { /** * Delegates to [InvoiceListPageResponse], but gracefully handles missing data. @@ -33,30 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): InvoiceListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): InvoiceListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): InvoiceListParams = params @@ -125,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: InvoiceListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 4ae13b3a..495115c3 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.InvoiceServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [InvoiceServiceAsync.list] */ class InvoiceListPageAsync private constructor( private val service: InvoiceServiceAsync, + private val streamHandlerExecutor: Executor, private val params: InvoiceListParams, private val response: InvoiceListPageResponse, -) { +) : PageAsync { /** * Delegates to [InvoiceListPageResponse], but gracefully handles missing data. @@ -34,33 +36,23 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): InvoiceListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): InvoiceListParams = params @@ -78,6 +70,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -89,18 +82,24 @@ private constructor( class Builder internal constructor() { private var service: InvoiceServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: InvoiceListParams? = null private var response: InvoiceListPageResponse? = null @JvmSynthetic internal fun from(invoiceListPageAsync: InvoiceListPageAsync) = apply { service = invoiceListPageAsync.service + streamHandlerExecutor = invoiceListPageAsync.streamHandlerExecutor params = invoiceListPageAsync.params response = invoiceListPageAsync.response } fun service(service: InvoiceServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: InvoiceListParams) = apply { this.params = params } @@ -115,6 +114,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -124,47 +124,22 @@ private constructor( fun build(): InvoiceListPageAsync = InvoiceListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: InvoiceListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Invoice) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is InvoiceListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is InvoiceListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "InvoiceListPageAsync{service=$service, params=$params, response=$response}" + "InvoiceListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 70baf6a6..aa7500b7 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 @@ -27,13 +27,13 @@ import kotlin.jvm.optionals.getOrNull */ class InvoiceMarkPaidParams private constructor( - private val invoiceId: String, + private val invoiceId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun invoiceId(): String = invoiceId + fun invoiceId(): Optional = Optional.ofNullable(invoiceId) /** * A date string to specify the date of the payment. @@ -96,7 +96,6 @@ private constructor( * * The following fields are required: * ```java - * .invoiceId() * .paymentReceivedDate() * ``` */ @@ -119,7 +118,10 @@ private constructor( additionalQueryParams = invoiceMarkPaidParams.additionalQueryParams.toBuilder() } - fun invoiceId(invoiceId: String) = apply { this.invoiceId = invoiceId } + fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } + + /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.getOrNull()) /** * Sets the entire request body. @@ -301,7 +303,6 @@ private constructor( * * The following fields are required: * ```java - * .invoiceId() * .paymentReceivedDate() * ``` * @@ -309,7 +310,7 @@ private constructor( */ fun build(): InvoiceMarkPaidParams = InvoiceMarkPaidParams( - checkRequired("invoiceId", invoiceId), + invoiceId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -320,7 +321,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> invoiceId + 0 -> invoiceId ?: "" else -> "" } 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 d0ad59cc..1328a2ff 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint collects payment for an invoice using the customer's default payment method. This @@ -17,13 +17,13 @@ import java.util.Optional */ class InvoicePayParams private constructor( - private val invoiceId: String, + private val invoiceId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun invoiceId(): String = invoiceId + fun invoiceId(): Optional = Optional.ofNullable(invoiceId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -35,14 +35,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [InvoicePayParams]. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - */ + @JvmStatic fun none(): InvoicePayParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InvoicePayParams]. */ @JvmStatic fun builder() = Builder() } @@ -62,7 +57,10 @@ private constructor( additionalBodyProperties = invoicePayParams.additionalBodyProperties.toMutableMap() } - fun invoiceId(invoiceId: String) = apply { this.invoiceId = invoiceId } + fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } + + /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -188,17 +186,10 @@ private constructor( * Returns an immutable instance of [InvoicePayParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): InvoicePayParams = InvoicePayParams( - checkRequired("invoiceId", invoiceId), + invoiceId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -210,7 +201,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> invoiceId + 0 -> invoiceId ?: "" else -> "" } 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 c8d560f4..7ec4c10d 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 @@ -11,7 +11,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -29,13 +28,13 @@ import kotlin.jvm.optionals.getOrNull */ class InvoiceUpdateParams private constructor( - private val invoiceId: String, + private val invoiceId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun invoiceId(): String = invoiceId + fun invoiceId(): Optional = Optional.ofNullable(invoiceId) /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting @@ -64,14 +63,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [InvoiceUpdateParams]. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - */ + @JvmStatic fun none(): InvoiceUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InvoiceUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -91,7 +85,10 @@ private constructor( additionalQueryParams = invoiceUpdateParams.additionalQueryParams.toBuilder() } - fun invoiceId(invoiceId: String) = apply { this.invoiceId = invoiceId } + fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } + + /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.getOrNull()) /** * Sets the entire request body. @@ -242,17 +239,10 @@ private constructor( * Returns an immutable instance of [InvoiceUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): InvoiceUpdateParams = InvoiceUpdateParams( - checkRequired("invoiceId", invoiceId), + invoiceId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -263,7 +253,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> invoiceId + 0 -> invoiceId ?: "" else -> "" } 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 3ecd331d..6824d660 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects 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 @@ -24,13 +24,13 @@ import java.util.Optional */ class InvoiceVoidInvoiceParams private constructor( - private val invoiceId: String, + private val invoiceId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun invoiceId(): String = invoiceId + fun invoiceId(): Optional = Optional.ofNullable(invoiceId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -42,14 +42,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [InvoiceVoidInvoiceParams]. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - */ + @JvmStatic fun none(): InvoiceVoidInvoiceParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [InvoiceVoidInvoiceParams]. */ @JvmStatic fun builder() = Builder() } @@ -70,7 +65,10 @@ private constructor( invoiceVoidInvoiceParams.additionalBodyProperties.toMutableMap() } - fun invoiceId(invoiceId: String) = apply { this.invoiceId = invoiceId } + fun invoiceId(invoiceId: String?) = apply { this.invoiceId = invoiceId } + + /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -196,17 +194,10 @@ private constructor( * Returns an immutable instance of [InvoiceVoidInvoiceParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .invoiceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams( - checkRequired("invoiceId", invoiceId), + invoiceId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -218,7 +209,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> invoiceId + 0 -> invoiceId ?: "" else -> "" } 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 8d1f7aa4..2576c3bf 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 @@ -3,20 +3,21 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** This endpoint returns an item identified by its item_id. */ class ItemFetchParams private constructor( - private val itemId: String, + private val itemId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun itemId(): String = itemId + fun itemId(): Optional = Optional.ofNullable(itemId) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [ItemFetchParams]. - * - * The following fields are required: - * ```java - * .itemId() - * ``` - */ + @JvmStatic fun none(): ItemFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ItemFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = itemFetchParams.additionalQueryParams.toBuilder() } - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String?) = apply { this.itemId = itemId } + + /** Alias for calling [Builder.itemId] with `itemId.orElse(null)`. */ + fun itemId(itemId: Optional) = itemId(itemId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,25 +154,14 @@ private constructor( * Returns an immutable instance of [ItemFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .itemId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): ItemFetchParams = - ItemFetchParams( - checkRequired("itemId", itemId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + ItemFetchParams(itemId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> itemId + 0 -> itemId ?: "" else -> "" } 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 49f8acf1..4a725205 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.ItemService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [ItemService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: ItemService, private val params: ItemListParams, private val response: ItemListPageResponse, -) { +) : Page { /** * Delegates to [ItemListPageResponse], but gracefully handles missing data. @@ -33,30 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): ItemListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): ItemListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): ItemListParams = params @@ -125,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: ItemListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 fb75f340..89d544c9 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.ItemServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [ItemServiceAsync.list] */ class ItemListPageAsync private constructor( private val service: ItemServiceAsync, + private val streamHandlerExecutor: Executor, private val params: ItemListParams, private val response: ItemListPageResponse, -) { +) : PageAsync { /** * Delegates to [ItemListPageResponse], but gracefully handles missing data. @@ -34,33 +36,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): ItemListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): ItemListParams = params @@ -78,6 +69,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -89,18 +81,24 @@ private constructor( class Builder internal constructor() { private var service: ItemServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: ItemListParams? = null private var response: ItemListPageResponse? = null @JvmSynthetic internal fun from(itemListPageAsync: ItemListPageAsync) = apply { service = itemListPageAsync.service + streamHandlerExecutor = itemListPageAsync.streamHandlerExecutor params = itemListPageAsync.params response = itemListPageAsync.response } fun service(service: ItemServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: ItemListParams) = apply { this.params = params } @@ -115,6 +113,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -124,47 +123,22 @@ private constructor( fun build(): ItemListPageAsync = ItemListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: ItemListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Item) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ItemListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is ItemListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "ItemListPageAsync{service=$service, params=$params, response=$response}" + "ItemListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 3d5f2858..4982da3f 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 @@ -26,13 +26,13 @@ import kotlin.jvm.optionals.getOrNull /** This endpoint can be used to update properties on the Item. */ class ItemUpdateParams private constructor( - private val itemId: String, + private val itemId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun itemId(): String = itemId + fun itemId(): Optional = Optional.ofNullable(itemId) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type (e.g. if the server @@ -71,14 +71,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [ItemUpdateParams]. - * - * The following fields are required: - * ```java - * .itemId() - * ``` - */ + @JvmStatic fun none(): ItemUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ItemUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -98,7 +93,10 @@ private constructor( additionalQueryParams = itemUpdateParams.additionalQueryParams.toBuilder() } - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String?) = apply { this.itemId = itemId } + + /** Alias for calling [Builder.itemId] with `itemId.orElse(null)`. */ + fun itemId(itemId: Optional) = itemId(itemId.getOrNull()) /** * Sets the entire request body. @@ -274,17 +272,10 @@ private constructor( * Returns an immutable instance of [ItemUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .itemId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): ItemUpdateParams = ItemUpdateParams( - checkRequired("itemId", itemId), + itemId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -295,7 +286,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> itemId + 0 -> itemId ?: "" else -> "" } 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 10e97ce0..91f6de6b 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about the @@ -14,12 +15,12 @@ import java.util.Objects */ class MetricFetchParams private constructor( - private val metricId: String, + private val metricId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun metricId(): String = metricId + fun metricId(): Optional = Optional.ofNullable(metricId) fun _additionalHeaders(): Headers = additionalHeaders @@ -29,14 +30,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [MetricFetchParams]. - * - * The following fields are required: - * ```java - * .metricId() - * ``` - */ + @JvmStatic fun none(): MetricFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MetricFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -54,7 +50,10 @@ private constructor( additionalQueryParams = metricFetchParams.additionalQueryParams.toBuilder() } - fun metricId(metricId: String) = apply { this.metricId = metricId } + fun metricId(metricId: String?) = apply { this.metricId = metricId } + + /** Alias for calling [Builder.metricId] with `metricId.orElse(null)`. */ + fun metricId(metricId: Optional) = metricId(metricId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -158,25 +157,14 @@ private constructor( * Returns an immutable instance of [MetricFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metricId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): MetricFetchParams = - MetricFetchParams( - checkRequired("metricId", metricId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + MetricFetchParams(metricId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> metricId + 0 -> metricId ?: "" else -> "" } 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 bd8cb504..5c32106c 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.MetricService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [MetricService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: MetricService, private val params: MetricListParams, private val response: MetricListPageResponse, -) { +) : Page { /** * Delegates to [MetricListPageResponse], but gracefully handles missing data. @@ -34,30 +34,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): MetricListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): MetricListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): MetricListParams = params @@ -126,25 +118,6 @@ private constructor( ) } - class AutoPager(private val firstPage: MetricListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 9f509035..78d94132 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.MetricServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [MetricServiceAsync.list] */ class MetricListPageAsync private constructor( private val service: MetricServiceAsync, + private val streamHandlerExecutor: Executor, private val params: MetricListParams, private val response: MetricListPageResponse, -) { +) : PageAsync { /** * Delegates to [MetricListPageResponse], but gracefully handles missing data. @@ -35,33 +37,23 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): MetricListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): MetricListParams = params @@ -79,6 +71,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -90,18 +83,24 @@ private constructor( class Builder internal constructor() { private var service: MetricServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: MetricListParams? = null private var response: MetricListPageResponse? = null @JvmSynthetic internal fun from(metricListPageAsync: MetricListPageAsync) = apply { service = metricListPageAsync.service + streamHandlerExecutor = metricListPageAsync.streamHandlerExecutor params = metricListPageAsync.params response = metricListPageAsync.response } fun service(service: MetricServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: MetricListParams) = apply { this.params = params } @@ -116,6 +115,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -125,50 +125,22 @@ private constructor( fun build(): MetricListPageAsync = MetricListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: MetricListPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (BillableMetric) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is MetricListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is MetricListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "MetricListPageAsync{service=$service, params=$params, response=$response}" + "MetricListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 d5b33a4c..83328fbf 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 @@ -11,7 +11,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -27,13 +26,13 @@ import kotlin.jvm.optionals.getOrNull */ class MetricUpdateParams private constructor( - private val metricId: String, + private val metricId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun metricId(): String = metricId + fun metricId(): Optional = Optional.ofNullable(metricId) /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting @@ -62,14 +61,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [MetricUpdateParams]. - * - * The following fields are required: - * ```java - * .metricId() - * ``` - */ + @JvmStatic fun none(): MetricUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MetricUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -89,7 +83,10 @@ private constructor( additionalQueryParams = metricUpdateParams.additionalQueryParams.toBuilder() } - fun metricId(metricId: String) = apply { this.metricId = metricId } + fun metricId(metricId: String?) = apply { this.metricId = metricId } + + /** Alias for calling [Builder.metricId] with `metricId.orElse(null)`. */ + fun metricId(metricId: Optional) = metricId(metricId.getOrNull()) /** * Sets the entire request body. @@ -240,17 +237,10 @@ private constructor( * Returns an immutable instance of [MetricUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metricId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): MetricUpdateParams = MetricUpdateParams( - checkRequired("metricId", metricId), + metricId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -261,7 +251,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> metricId + 0 -> metricId ?: "" else -> "" } 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 4ac065c9..483ecad4 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 @@ -651,39 +651,28 @@ private constructor( } } - /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun addAdjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - addAdjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [addAdjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun addAdjustment(usageDiscount: Adjustment.UsageDiscount) = + addAdjustment(Adjustment.ofUsageDiscount(usageDiscount)) - /** - * Alias for calling [addAdjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. - */ - fun addAdjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - addAdjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + /** Alias for calling [addAdjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ + fun addAdjustment(amountDiscount: Adjustment.AmountDiscount) = + addAdjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [addAdjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun addAdjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = addAdjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun addAdjustment(percentageDiscount: Adjustment.PercentageDiscount) = + addAdjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [addAdjustment] with `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun addAdjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - addAdjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [addAdjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun addAdjustment(minimum: Adjustment.Minimum) = + addAdjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [addAdjustment] with `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun addAdjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - addAdjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [addAdjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun addAdjustment(maximum: Adjustment.Maximum) = + addAdjustment(Adjustment.ofMaximum(maximum)) fun basePlan(basePlan: BasePlan?) = basePlan(JsonField.ofNullable(basePlan)) @@ -1033,137 +1022,136 @@ private constructor( } /** Alias for calling [addPrice] with `Price.ofUnit(unit)`. */ - fun addPrice(unit: Price.UnitPrice) = addPrice(Price.ofUnit(unit)) + fun addPrice(unit: Price.Unit) = addPrice(Price.ofUnit(unit)) - /** Alias for calling [addPrice] with `Price.ofPackagePrice(packagePrice)`. */ - fun addPrice(packagePrice: Price.PackagePrice) = - addPrice(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = addPrice(Price.ofMatrix(matrix)) + fun addPrice(matrix: Price.Matrix) = addPrice(Price.ofMatrix(matrix)) /** Alias for calling [addPrice] with `Price.ofTiered(tiered)`. */ - fun addPrice(tiered: Price.TieredPrice) = addPrice(Price.ofTiered(tiered)) + fun addPrice(tiered: Price.Tiered) = addPrice(Price.ofTiered(tiered)) /** Alias for calling [addPrice] with `Price.ofTieredBps(tieredBps)`. */ - fun addPrice(tieredBps: Price.TieredBpsPrice) = addPrice(Price.ofTieredBps(tieredBps)) + fun addPrice(tieredBps: Price.TieredBps) = addPrice(Price.ofTieredBps(tieredBps)) /** Alias for calling [addPrice] with `Price.ofBps(bps)`. */ - fun addPrice(bps: Price.BpsPrice) = addPrice(Price.ofBps(bps)) + fun addPrice(bps: Price.Bps) = addPrice(Price.ofBps(bps)) /** Alias for calling [addPrice] with `Price.ofBulkBps(bulkBps)`. */ - fun addPrice(bulkBps: Price.BulkBpsPrice) = addPrice(Price.ofBulkBps(bulkBps)) + fun addPrice(bulkBps: Price.BulkBps) = addPrice(Price.ofBulkBps(bulkBps)) /** Alias for calling [addPrice] with `Price.ofBulk(bulk)`. */ - fun addPrice(bulk: Price.BulkPrice) = addPrice(Price.ofBulk(bulk)) + fun addPrice(bulk: Price.Bulk) = addPrice(Price.ofBulk(bulk)) /** * Alias for calling [addPrice] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun addPrice(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun addPrice(thresholdTotalAmount: Price.ThresholdTotalAmount) = addPrice(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [addPrice] with `Price.ofTieredPackage(tieredPackage)`. */ - fun addPrice(tieredPackage: Price.TieredPackagePrice) = + fun addPrice(tieredPackage: Price.TieredPackage) = addPrice(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [addPrice] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun addPrice(groupedTiered: Price.GroupedTieredPrice) = + fun addPrice(groupedTiered: Price.GroupedTiered) = addPrice(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [addPrice] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun addPrice(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun addPrice(tieredWithMinimum: Price.TieredWithMinimum) = addPrice(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [addPrice] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun addPrice(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun addPrice(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = addPrice(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [addPrice] with `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun addPrice(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun addPrice(packageWithAllocation: Price.PackageWithAllocation) = addPrice(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [addPrice] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun addPrice(unitWithPercent: Price.UnitWithPercentPrice) = + fun addPrice(unitWithPercent: Price.UnitWithPercent) = addPrice(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [addPrice] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun addPrice(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun addPrice(matrixWithAllocation: Price.MatrixWithAllocation) = addPrice(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** Alias for calling [addPrice] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun addPrice(tieredWithProration: Price.TieredWithProrationPrice) = + fun addPrice(tieredWithProration: Price.TieredWithProration) = addPrice(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [addPrice] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun addPrice(unitWithProration: Price.UnitWithProrationPrice) = + fun addPrice(unitWithProration: Price.UnitWithProration) = addPrice(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [addPrice] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun addPrice(groupedAllocation: Price.GroupedAllocationPrice) = + fun addPrice(groupedAllocation: Price.GroupedAllocation) = addPrice(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [addPrice] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun addPrice(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun addPrice(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = addPrice(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [addPrice] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun addPrice(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun addPrice(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = addPrice(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [addPrice] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun addPrice(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun addPrice(matrixWithDisplayName: Price.MatrixWithDisplayName) = addPrice(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [addPrice] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun addPrice(bulkWithProration: Price.BulkWithProrationPrice) = + fun addPrice(bulkWithProration: Price.BulkWithProration) = addPrice(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [addPrice] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun addPrice(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun addPrice(groupedTieredPackage: Price.GroupedTieredPackage) = addPrice(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [addPrice] with `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun addPrice(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun addPrice(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = addPrice(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [addPrice] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun addPrice(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun addPrice(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = addPrice(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [addPrice] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun addPrice(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun addPrice(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = addPrice(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [addPrice] with `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun addPrice(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun addPrice(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = addPrice(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) fun product(product: Product) = product(JsonField.of(product)) @@ -1371,66 +1359,55 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1443,34 +1420,24 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) { - planPhasePercentageDiscount.validate() + override fun visitPercentageDiscount(percentageDiscount: PercentageDiscount) { + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -1495,25 +1462,18 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount(percentageDiscount: PercentageDiscount) = + percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1524,21 +1484,18 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -1546,26 +1503,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount(planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment) = - Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -1573,21 +1524,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -1613,38 +1558,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -1660,24 +1596,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -1691,7 +1625,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -1726,11 +1660,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -1785,16 +1725,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -1857,13 +1787,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -1874,11 +1802,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -1887,21 +1815,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType - appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType + appliesToPriceIds = usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -1915,17 +1837,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2058,14 +1982,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2075,10 +1998,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2092,13 +2015,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2124,147 +2051,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("usage_discount")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2274,13 +2073,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2294,7 +2093,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2327,11 +2126,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2386,16 +2191,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -2458,13 +2253,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -2475,11 +2268,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -2488,21 +2281,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount - appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount + appliesToPriceIds = amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2516,17 +2303,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2659,14 +2448,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -2676,10 +2464,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -2693,13 +2481,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -2725,147 +2517,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("amount_discount")) 1 else 0 } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2875,13 +2539,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -2895,7 +2559,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2928,11 +2592,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2987,16 +2657,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3059,13 +2719,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3076,11 +2734,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3089,21 +2747,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason - additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties.toMutableMap() + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason + additionalProperties = percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3117,17 +2770,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3260,14 +2915,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3277,10 +2931,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3294,13 +2948,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3326,147 +2984,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3476,13 +3008,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -3497,7 +3029,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3534,11 +3066,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3602,16 +3140,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3681,13 +3209,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -3699,11 +3225,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -3713,18 +3239,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3738,17 +3262,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3893,14 +3419,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -3911,10 +3436,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3929,13 +3454,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -3962,7 +3491,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -3970,140 +3499,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4113,13 +3514,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4133,7 +3534,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4166,11 +3567,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4225,16 +3632,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4297,13 +3694,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4314,11 +3709,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4327,17 +3722,15 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -4351,17 +3744,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4494,14 +3889,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4511,10 +3905,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4528,13 +3922,17 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException("'adjustmentType' is invalid, received $it") + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -4560,147 +3958,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4710,7 +3980,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } 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 de56dcf2..0d7fd9a1 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 @@ -31,6 +31,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.Unit as KUnit import kotlin.jvm.optionals.getOrNull /** This endpoint allows creation of plans including their prices. */ @@ -257,179 +258,137 @@ private constructor( */ fun addPrice(price: Price) = apply { body.addPrice(price) } - /** Alias for calling [addPrice] with `Price.ofNewPlanUnit(newPlanUnit)`. */ - fun addPrice(newPlanUnit: Price.NewPlanUnitPrice) = apply { body.addPrice(newPlanUnit) } + /** Alias for calling [addPrice] with `Price.ofUnit(unit)`. */ + fun addPrice(unit: Price.Unit) = apply { body.addPrice(unit) } - /** Alias for calling [addPrice] with `Price.ofNewPlanPackage(newPlanPackage)`. */ - fun addPrice(newPlanPackage: Price.NewPlanPackagePrice) = apply { - body.addPrice(newPlanPackage) - } + /** Alias for calling [addPrice] with `Price.ofPackage(package_)`. */ + fun addPrice(package_: Price.Package) = apply { body.addPrice(package_) } - /** Alias for calling [addPrice] with `Price.ofNewPlanMatrix(newPlanMatrix)`. */ - fun addPrice(newPlanMatrix: Price.NewPlanMatrixPrice) = apply { - body.addPrice(newPlanMatrix) - } + /** Alias for calling [addPrice] with `Price.ofMatrix(matrix)`. */ + fun addPrice(matrix: Price.Matrix) = apply { body.addPrice(matrix) } - /** Alias for calling [addPrice] with `Price.ofNewPlanTiered(newPlanTiered)`. */ - fun addPrice(newPlanTiered: Price.NewPlanTieredPrice) = apply { - body.addPrice(newPlanTiered) - } + /** Alias for calling [addPrice] with `Price.ofTiered(tiered)`. */ + fun addPrice(tiered: Price.Tiered) = apply { body.addPrice(tiered) } - /** Alias for calling [addPrice] with `Price.ofNewPlanTieredBps(newPlanTieredBps)`. */ - fun addPrice(newPlanTieredBps: Price.NewPlanTieredBpsPrice) = apply { - body.addPrice(newPlanTieredBps) - } + /** Alias for calling [addPrice] with `Price.ofTieredBps(tieredBps)`. */ + fun addPrice(tieredBps: Price.TieredBps) = apply { body.addPrice(tieredBps) } - /** Alias for calling [addPrice] with `Price.ofNewPlanBps(newPlanBps)`. */ - fun addPrice(newPlanBps: Price.NewPlanBpsPrice) = apply { body.addPrice(newPlanBps) } + /** Alias for calling [addPrice] with `Price.ofBps(bps)`. */ + fun addPrice(bps: Price.Bps) = apply { body.addPrice(bps) } - /** Alias for calling [addPrice] with `Price.ofNewPlanBulkBps(newPlanBulkBps)`. */ - fun addPrice(newPlanBulkBps: Price.NewPlanBulkBpsPrice) = apply { - body.addPrice(newPlanBulkBps) - } + /** Alias for calling [addPrice] with `Price.ofBulkBps(bulkBps)`. */ + fun addPrice(bulkBps: Price.BulkBps) = apply { body.addPrice(bulkBps) } - /** Alias for calling [addPrice] with `Price.ofNewPlanBulk(newPlanBulk)`. */ - fun addPrice(newPlanBulk: Price.NewPlanBulkPrice) = apply { body.addPrice(newPlanBulk) } + /** Alias for calling [addPrice] with `Price.ofBulk(bulk)`. */ + fun addPrice(bulk: Price.Bulk) = apply { body.addPrice(bulk) } /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanThresholdTotalAmount(newPlanThresholdTotalAmount)`. + * Alias for calling [addPrice] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun addPrice(newPlanThresholdTotalAmount: Price.NewPlanThresholdTotalAmountPrice) = apply { - body.addPrice(newPlanThresholdTotalAmount) + fun addPrice(thresholdTotalAmount: Price.ThresholdTotalAmount) = apply { + body.addPrice(thresholdTotalAmount) } - /** - * Alias for calling [addPrice] with `Price.ofNewPlanTieredPackage(newPlanTieredPackage)`. - */ - fun addPrice(newPlanTieredPackage: Price.NewPlanTieredPackagePrice) = apply { - body.addPrice(newPlanTieredPackage) + /** Alias for calling [addPrice] with `Price.ofTieredPackage(tieredPackage)`. */ + fun addPrice(tieredPackage: Price.TieredPackage) = apply { body.addPrice(tieredPackage) } + + /** Alias for calling [addPrice] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun addPrice(tieredWithMinimum: Price.TieredWithMinimum) = apply { + body.addPrice(tieredWithMinimum) } - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanTieredWithMinimum(newPlanTieredWithMinimum)`. - */ - fun addPrice(newPlanTieredWithMinimum: Price.NewPlanTieredWithMinimumPrice) = apply { - body.addPrice(newPlanTieredWithMinimum) + /** Alias for calling [addPrice] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun addPrice(unitWithPercent: Price.UnitWithPercent) = apply { + body.addPrice(unitWithPercent) } /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanUnitWithPercent(newPlanUnitWithPercent)`. + * Alias for calling [addPrice] with `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun addPrice(newPlanUnitWithPercent: Price.NewPlanUnitWithPercentPrice) = apply { - body.addPrice(newPlanUnitWithPercent) + fun addPrice(packageWithAllocation: Price.PackageWithAllocation) = apply { + body.addPrice(packageWithAllocation) } - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanPackageWithAllocation(newPlanPackageWithAllocation)`. - */ - fun addPrice(newPlanPackageWithAllocation: Price.NewPlanPackageWithAllocationPrice) = - apply { - body.addPrice(newPlanPackageWithAllocation) - } + /** Alias for calling [addPrice] with `Price.ofTieredWithProration(tieredWithProration)`. */ + fun addPrice(tieredWithProration: Price.TieredWithProration) = apply { + body.addPrice(tieredWithProration) + } - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanTierWithProration(newPlanTierWithProration)`. - */ - fun addPrice(newPlanTierWithProration: Price.NewPlanTierWithProrationPrice) = apply { - body.addPrice(newPlanTierWithProration) + /** Alias for calling [addPrice] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun addPrice(unitWithProration: Price.UnitWithProration) = apply { + body.addPrice(unitWithProration) } - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanUnitWithProration(newPlanUnitWithProration)`. - */ - fun addPrice(newPlanUnitWithProration: Price.NewPlanUnitWithProrationPrice) = apply { - body.addPrice(newPlanUnitWithProration) + /** Alias for calling [addPrice] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun addPrice(groupedAllocation: Price.GroupedAllocation) = apply { + body.addPrice(groupedAllocation) } /** * Alias for calling [addPrice] with - * `Price.ofNewPlanGroupedAllocation(newPlanGroupedAllocation)`. + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun addPrice(newPlanGroupedAllocation: Price.NewPlanGroupedAllocationPrice) = apply { - body.addPrice(newPlanGroupedAllocation) + fun addPrice(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = apply { + body.addPrice(groupedWithProratedMinimum) } /** * Alias for calling [addPrice] with - * `Price.ofNewPlanGroupedWithProratedMinimum(newPlanGroupedWithProratedMinimum)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun addPrice( - newPlanGroupedWithProratedMinimum: Price.NewPlanGroupedWithProratedMinimumPrice - ) = apply { body.addPrice(newPlanGroupedWithProratedMinimum) } + fun addPrice(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = apply { + body.addPrice(groupedWithMeteredMinimum) + } /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanGroupedWithMeteredMinimum(newPlanGroupedWithMeteredMinimum)`. + * Alias for calling [addPrice] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun addPrice( - newPlanGroupedWithMeteredMinimum: Price.NewPlanGroupedWithMeteredMinimumPrice - ) = apply { body.addPrice(newPlanGroupedWithMeteredMinimum) } + fun addPrice(matrixWithDisplayName: Price.MatrixWithDisplayName) = apply { + body.addPrice(matrixWithDisplayName) + } + + /** Alias for calling [addPrice] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun addPrice(bulkWithProration: Price.BulkWithProration) = apply { + body.addPrice(bulkWithProration) + } /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanMatrixWithDisplayName(newPlanMatrixWithDisplayName)`. + * Alias for calling [addPrice] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun addPrice(newPlanMatrixWithDisplayName: Price.NewPlanMatrixWithDisplayNamePrice) = - apply { - body.addPrice(newPlanMatrixWithDisplayName) - } + fun addPrice(groupedTieredPackage: Price.GroupedTieredPackage) = apply { + body.addPrice(groupedTieredPackage) + } /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanBulkWithProration(newPlanBulkWithProration)`. + * Alias for calling [addPrice] with `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun addPrice(newPlanBulkWithProration: Price.NewPlanBulkWithProrationPrice) = apply { - body.addPrice(newPlanBulkWithProration) + fun addPrice(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = apply { + body.addPrice(maxGroupTieredPackage) } /** * Alias for calling [addPrice] with - * `Price.ofNewPlanGroupedTieredPackage(newPlanGroupedTieredPackage)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun addPrice(newPlanGroupedTieredPackage: Price.NewPlanGroupedTieredPackagePrice) = apply { - body.addPrice(newPlanGroupedTieredPackage) + fun addPrice(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = apply { + body.addPrice(scalableMatrixWithUnitPricing) } /** * Alias for calling [addPrice] with - * `Price.ofNewPlanMaxGroupTieredPackage(newPlanMaxGroupTieredPackage)`. + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun addPrice(newPlanMaxGroupTieredPackage: Price.NewPlanMaxGroupTieredPackagePrice) = + fun addPrice(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = apply { - body.addPrice(newPlanMaxGroupTieredPackage) + body.addPrice(scalableMatrixWithTieredPricing) } /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanScalableMatrixWithUnitPricing(newPlanScalableMatrixWithUnitPricing)`. - */ - fun addPrice( - newPlanScalableMatrixWithUnitPricing: Price.NewPlanScalableMatrixWithUnitPricingPrice - ) = apply { body.addPrice(newPlanScalableMatrixWithUnitPricing) } - - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanScalableMatrixWithTieredPricing(newPlanScalableMatrixWithTieredPricing)`. + * Alias for calling [addPrice] with `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun addPrice( - newPlanScalableMatrixWithTieredPricing: - Price.NewPlanScalableMatrixWithTieredPricingPrice - ) = apply { body.addPrice(newPlanScalableMatrixWithTieredPricing) } - - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanCumulativeGroupedBulk(newPlanCumulativeGroupedBulk)`. - */ - fun addPrice(newPlanCumulativeGroupedBulk: Price.NewPlanCumulativeGroupedBulkPrice) = - apply { - body.addPrice(newPlanCumulativeGroupedBulk) - } + fun addPrice(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = apply { + body.addPrice(cumulativeGroupedBulk) + } /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = apply { @@ -946,175 +905,129 @@ private constructor( } } - /** Alias for calling [addPrice] with `Price.ofNewPlanUnit(newPlanUnit)`. */ - fun addPrice(newPlanUnit: Price.NewPlanUnitPrice) = - addPrice(Price.ofNewPlanUnit(newPlanUnit)) + /** Alias for calling [addPrice] with `Price.ofUnit(unit)`. */ + fun addPrice(unit: Price.Unit) = addPrice(Price.ofUnit(unit)) - /** Alias for calling [addPrice] with `Price.ofNewPlanPackage(newPlanPackage)`. */ - fun addPrice(newPlanPackage: Price.NewPlanPackagePrice) = - addPrice(Price.ofNewPlanPackage(newPlanPackage)) + /** Alias for calling [addPrice] with `Price.ofPackage(package_)`. */ + fun addPrice(package_: Price.Package) = addPrice(Price.ofPackage(package_)) - /** Alias for calling [addPrice] with `Price.ofNewPlanMatrix(newPlanMatrix)`. */ - fun addPrice(newPlanMatrix: Price.NewPlanMatrixPrice) = - addPrice(Price.ofNewPlanMatrix(newPlanMatrix)) + /** Alias for calling [addPrice] with `Price.ofMatrix(matrix)`. */ + fun addPrice(matrix: Price.Matrix) = addPrice(Price.ofMatrix(matrix)) - /** Alias for calling [addPrice] with `Price.ofNewPlanTiered(newPlanTiered)`. */ - fun addPrice(newPlanTiered: Price.NewPlanTieredPrice) = - addPrice(Price.ofNewPlanTiered(newPlanTiered)) + /** Alias for calling [addPrice] with `Price.ofTiered(tiered)`. */ + fun addPrice(tiered: Price.Tiered) = addPrice(Price.ofTiered(tiered)) - /** Alias for calling [addPrice] with `Price.ofNewPlanTieredBps(newPlanTieredBps)`. */ - fun addPrice(newPlanTieredBps: Price.NewPlanTieredBpsPrice) = - addPrice(Price.ofNewPlanTieredBps(newPlanTieredBps)) + /** Alias for calling [addPrice] with `Price.ofTieredBps(tieredBps)`. */ + fun addPrice(tieredBps: Price.TieredBps) = addPrice(Price.ofTieredBps(tieredBps)) - /** Alias for calling [addPrice] with `Price.ofNewPlanBps(newPlanBps)`. */ - fun addPrice(newPlanBps: Price.NewPlanBpsPrice) = - addPrice(Price.ofNewPlanBps(newPlanBps)) + /** Alias for calling [addPrice] with `Price.ofBps(bps)`. */ + fun addPrice(bps: Price.Bps) = addPrice(Price.ofBps(bps)) - /** Alias for calling [addPrice] with `Price.ofNewPlanBulkBps(newPlanBulkBps)`. */ - fun addPrice(newPlanBulkBps: Price.NewPlanBulkBpsPrice) = - addPrice(Price.ofNewPlanBulkBps(newPlanBulkBps)) + /** Alias for calling [addPrice] with `Price.ofBulkBps(bulkBps)`. */ + fun addPrice(bulkBps: Price.BulkBps) = addPrice(Price.ofBulkBps(bulkBps)) - /** Alias for calling [addPrice] with `Price.ofNewPlanBulk(newPlanBulk)`. */ - fun addPrice(newPlanBulk: Price.NewPlanBulkPrice) = - addPrice(Price.ofNewPlanBulk(newPlanBulk)) + /** Alias for calling [addPrice] with `Price.ofBulk(bulk)`. */ + fun addPrice(bulk: Price.Bulk) = addPrice(Price.ofBulk(bulk)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanThresholdTotalAmount(newPlanThresholdTotalAmount)`. + * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun addPrice(newPlanThresholdTotalAmount: Price.NewPlanThresholdTotalAmountPrice) = - addPrice(Price.ofNewPlanThresholdTotalAmount(newPlanThresholdTotalAmount)) + fun addPrice(thresholdTotalAmount: Price.ThresholdTotalAmount) = + addPrice(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanTieredPackage(newPlanTieredPackage)`. - */ - fun addPrice(newPlanTieredPackage: Price.NewPlanTieredPackagePrice) = - addPrice(Price.ofNewPlanTieredPackage(newPlanTieredPackage)) + /** Alias for calling [addPrice] with `Price.ofTieredPackage(tieredPackage)`. */ + fun addPrice(tieredPackage: Price.TieredPackage) = + addPrice(Price.ofTieredPackage(tieredPackage)) - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanTieredWithMinimum(newPlanTieredWithMinimum)`. - */ - fun addPrice(newPlanTieredWithMinimum: Price.NewPlanTieredWithMinimumPrice) = - addPrice(Price.ofNewPlanTieredWithMinimum(newPlanTieredWithMinimum)) + /** Alias for calling [addPrice] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun addPrice(tieredWithMinimum: Price.TieredWithMinimum) = + addPrice(Price.ofTieredWithMinimum(tieredWithMinimum)) - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanUnitWithPercent(newPlanUnitWithPercent)`. - */ - fun addPrice(newPlanUnitWithPercent: Price.NewPlanUnitWithPercentPrice) = - addPrice(Price.ofNewPlanUnitWithPercent(newPlanUnitWithPercent)) + /** Alias for calling [addPrice] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun addPrice(unitWithPercent: Price.UnitWithPercent) = + addPrice(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanPackageWithAllocation(newPlanPackageWithAllocation)`. + * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun addPrice(newPlanPackageWithAllocation: Price.NewPlanPackageWithAllocationPrice) = - addPrice(Price.ofNewPlanPackageWithAllocation(newPlanPackageWithAllocation)) + fun addPrice(packageWithAllocation: Price.PackageWithAllocation) = + addPrice(Price.ofPackageWithAllocation(packageWithAllocation)) /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanTierWithProration(newPlanTierWithProration)`. + * Alias for calling [addPrice] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun addPrice(newPlanTierWithProration: Price.NewPlanTierWithProrationPrice) = - addPrice(Price.ofNewPlanTierWithProration(newPlanTierWithProration)) + fun addPrice(tieredWithProration: Price.TieredWithProration) = + addPrice(Price.ofTieredWithProration(tieredWithProration)) - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanUnitWithProration(newPlanUnitWithProration)`. - */ - fun addPrice(newPlanUnitWithProration: Price.NewPlanUnitWithProrationPrice) = - addPrice(Price.ofNewPlanUnitWithProration(newPlanUnitWithProration)) + /** Alias for calling [addPrice] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun addPrice(unitWithProration: Price.UnitWithProration) = + addPrice(Price.ofUnitWithProration(unitWithProration)) - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanGroupedAllocation(newPlanGroupedAllocation)`. - */ - fun addPrice(newPlanGroupedAllocation: Price.NewPlanGroupedAllocationPrice) = - addPrice(Price.ofNewPlanGroupedAllocation(newPlanGroupedAllocation)) + /** Alias for calling [addPrice] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun addPrice(groupedAllocation: Price.GroupedAllocation) = + addPrice(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanGroupedWithProratedMinimum(newPlanGroupedWithProratedMinimum)`. + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun addPrice( - newPlanGroupedWithProratedMinimum: Price.NewPlanGroupedWithProratedMinimumPrice - ) = - addPrice( - Price.ofNewPlanGroupedWithProratedMinimum(newPlanGroupedWithProratedMinimum) - ) + fun addPrice(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = + addPrice(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanGroupedWithMeteredMinimum(newPlanGroupedWithMeteredMinimum)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun addPrice( - newPlanGroupedWithMeteredMinimum: Price.NewPlanGroupedWithMeteredMinimumPrice - ) = addPrice(Price.ofNewPlanGroupedWithMeteredMinimum(newPlanGroupedWithMeteredMinimum)) + fun addPrice(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = + addPrice(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanMatrixWithDisplayName(newPlanMatrixWithDisplayName)`. + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun addPrice(newPlanMatrixWithDisplayName: Price.NewPlanMatrixWithDisplayNamePrice) = - addPrice(Price.ofNewPlanMatrixWithDisplayName(newPlanMatrixWithDisplayName)) + fun addPrice(matrixWithDisplayName: Price.MatrixWithDisplayName) = + addPrice(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** - * Alias for calling [addPrice] with - * `Price.ofNewPlanBulkWithProration(newPlanBulkWithProration)`. - */ - fun addPrice(newPlanBulkWithProration: Price.NewPlanBulkWithProrationPrice) = - addPrice(Price.ofNewPlanBulkWithProration(newPlanBulkWithProration)) + /** Alias for calling [addPrice] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun addPrice(bulkWithProration: Price.BulkWithProration) = + addPrice(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanGroupedTieredPackage(newPlanGroupedTieredPackage)`. + * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun addPrice(newPlanGroupedTieredPackage: Price.NewPlanGroupedTieredPackagePrice) = - addPrice(Price.ofNewPlanGroupedTieredPackage(newPlanGroupedTieredPackage)) + fun addPrice(groupedTieredPackage: Price.GroupedTieredPackage) = + addPrice(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanMaxGroupTieredPackage(newPlanMaxGroupTieredPackage)`. + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun addPrice(newPlanMaxGroupTieredPackage: Price.NewPlanMaxGroupTieredPackagePrice) = - addPrice(Price.ofNewPlanMaxGroupTieredPackage(newPlanMaxGroupTieredPackage)) + fun addPrice(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = + addPrice(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanScalableMatrixWithUnitPricing(newPlanScalableMatrixWithUnitPricing)`. - */ - fun addPrice( - newPlanScalableMatrixWithUnitPricing: - Price.NewPlanScalableMatrixWithUnitPricingPrice - ) = - addPrice( - Price.ofNewPlanScalableMatrixWithUnitPricing( - newPlanScalableMatrixWithUnitPricing - ) - ) + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. + */ + fun addPrice(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = + addPrice(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanScalableMatrixWithTieredPricing(newPlanScalableMatrixWithTieredPricing)`. - */ - fun addPrice( - newPlanScalableMatrixWithTieredPricing: - Price.NewPlanScalableMatrixWithTieredPricingPrice - ) = - addPrice( - Price.ofNewPlanScalableMatrixWithTieredPricing( - newPlanScalableMatrixWithTieredPricing - ) - ) + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. + */ + fun addPrice(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + addPrice(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [addPrice] with - * `Price.ofNewPlanCumulativeGroupedBulk(newPlanCumulativeGroupedBulk)`. + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun addPrice(newPlanCumulativeGroupedBulk: Price.NewPlanCumulativeGroupedBulkPrice) = - addPrice(Price.ofNewPlanCumulativeGroupedBulk(newPlanCumulativeGroupedBulk)) + fun addPrice(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = + addPrice(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = @@ -1327,285 +1240,253 @@ private constructor( @JsonSerialize(using = Price.Serializer::class) class Price private constructor( - private val newPlanUnit: NewPlanUnitPrice? = null, - private val newPlanPackage: NewPlanPackagePrice? = null, - private val newPlanMatrix: NewPlanMatrixPrice? = null, - private val newPlanTiered: NewPlanTieredPrice? = null, - private val newPlanTieredBps: NewPlanTieredBpsPrice? = null, - private val newPlanBps: NewPlanBpsPrice? = null, - private val newPlanBulkBps: NewPlanBulkBpsPrice? = null, - private val newPlanBulk: NewPlanBulkPrice? = null, - private val newPlanThresholdTotalAmount: NewPlanThresholdTotalAmountPrice? = null, - private val newPlanTieredPackage: NewPlanTieredPackagePrice? = null, - private val newPlanTieredWithMinimum: NewPlanTieredWithMinimumPrice? = null, - private val newPlanUnitWithPercent: NewPlanUnitWithPercentPrice? = null, - private val newPlanPackageWithAllocation: NewPlanPackageWithAllocationPrice? = null, - private val newPlanTierWithProration: NewPlanTierWithProrationPrice? = null, - private val newPlanUnitWithProration: NewPlanUnitWithProrationPrice? = null, - private val newPlanGroupedAllocation: NewPlanGroupedAllocationPrice? = null, - private val newPlanGroupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice? = - null, - private val newPlanGroupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice? = null, - private val newPlanMatrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice? = null, - private val newPlanBulkWithProration: NewPlanBulkWithProrationPrice? = null, - private val newPlanGroupedTieredPackage: NewPlanGroupedTieredPackagePrice? = null, - private val newPlanMaxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice? = null, - private val newPlanScalableMatrixWithUnitPricing: - NewPlanScalableMatrixWithUnitPricingPrice? = - null, - private val newPlanScalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice? = - null, - private val newPlanCumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice? = null, + 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 thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = 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 _json: JsonValue? = null, ) { - fun newPlanUnit(): Optional = Optional.ofNullable(newPlanUnit) + fun unit(): Optional = Optional.ofNullable(unit) - fun newPlanPackage(): Optional = Optional.ofNullable(newPlanPackage) + fun package_(): Optional = Optional.ofNullable(package_) - fun newPlanMatrix(): Optional = Optional.ofNullable(newPlanMatrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun newPlanTiered(): Optional = Optional.ofNullable(newPlanTiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun newPlanTieredBps(): Optional = - Optional.ofNullable(newPlanTieredBps) + fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - fun newPlanBps(): Optional = Optional.ofNullable(newPlanBps) + fun bps(): Optional = Optional.ofNullable(bps) - fun newPlanBulkBps(): Optional = Optional.ofNullable(newPlanBulkBps) + fun bulkBps(): Optional = Optional.ofNullable(bulkBps) - fun newPlanBulk(): Optional = Optional.ofNullable(newPlanBulk) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun newPlanThresholdTotalAmount(): Optional = - Optional.ofNullable(newPlanThresholdTotalAmount) + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) - fun newPlanTieredPackage(): Optional = - Optional.ofNullable(newPlanTieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun newPlanTieredWithMinimum(): Optional = - Optional.ofNullable(newPlanTieredWithMinimum) + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) - fun newPlanUnitWithPercent(): Optional = - Optional.ofNullable(newPlanUnitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun newPlanPackageWithAllocation(): Optional = - Optional.ofNullable(newPlanPackageWithAllocation) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) - fun newPlanTierWithProration(): Optional = - Optional.ofNullable(newPlanTierWithProration) + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) - fun newPlanUnitWithProration(): Optional = - Optional.ofNullable(newPlanUnitWithProration) + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) - fun newPlanGroupedAllocation(): Optional = - Optional.ofNullable(newPlanGroupedAllocation) + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) - fun newPlanGroupedWithProratedMinimum(): Optional = - Optional.ofNullable(newPlanGroupedWithProratedMinimum) + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) - fun newPlanGroupedWithMeteredMinimum(): Optional = - Optional.ofNullable(newPlanGroupedWithMeteredMinimum) + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) - fun newPlanMatrixWithDisplayName(): Optional = - Optional.ofNullable(newPlanMatrixWithDisplayName) + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) - fun newPlanBulkWithProration(): Optional = - Optional.ofNullable(newPlanBulkWithProration) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) - fun newPlanGroupedTieredPackage(): Optional = - Optional.ofNullable(newPlanGroupedTieredPackage) + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) - fun newPlanMaxGroupTieredPackage(): Optional = - Optional.ofNullable(newPlanMaxGroupTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) - fun newPlanScalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(newPlanScalableMatrixWithUnitPricing) + fun scalableMatrixWithUnitPricing(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) - fun newPlanScalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(newPlanScalableMatrixWithTieredPricing) + fun scalableMatrixWithTieredPricing(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) - fun newPlanCumulativeGroupedBulk(): Optional = - Optional.ofNullable(newPlanCumulativeGroupedBulk) + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) - fun isNewPlanUnit(): Boolean = newPlanUnit != null + fun isUnit(): Boolean = unit != null - fun isNewPlanPackage(): Boolean = newPlanPackage != null + fun isPackage(): Boolean = package_ != null - fun isNewPlanMatrix(): Boolean = newPlanMatrix != null + fun isMatrix(): Boolean = matrix != null - fun isNewPlanTiered(): Boolean = newPlanTiered != null + fun isTiered(): Boolean = tiered != null - fun isNewPlanTieredBps(): Boolean = newPlanTieredBps != null + fun isTieredBps(): Boolean = tieredBps != null - fun isNewPlanBps(): Boolean = newPlanBps != null + fun isBps(): Boolean = bps != null - fun isNewPlanBulkBps(): Boolean = newPlanBulkBps != null + fun isBulkBps(): Boolean = bulkBps != null - fun isNewPlanBulk(): Boolean = newPlanBulk != null + fun isBulk(): Boolean = bulk != null - fun isNewPlanThresholdTotalAmount(): Boolean = newPlanThresholdTotalAmount != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isNewPlanTieredPackage(): Boolean = newPlanTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null - fun isNewPlanTieredWithMinimum(): Boolean = newPlanTieredWithMinimum != null + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isNewPlanUnitWithPercent(): Boolean = newPlanUnitWithPercent != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun isNewPlanPackageWithAllocation(): Boolean = newPlanPackageWithAllocation != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun isNewPlanTierWithProration(): Boolean = newPlanTierWithProration != null + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun isNewPlanUnitWithProration(): Boolean = newPlanUnitWithProration != null + fun isUnitWithProration(): Boolean = unitWithProration != null - fun isNewPlanGroupedAllocation(): Boolean = newPlanGroupedAllocation != null + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isNewPlanGroupedWithProratedMinimum(): Boolean = - newPlanGroupedWithProratedMinimum != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun isNewPlanGroupedWithMeteredMinimum(): Boolean = newPlanGroupedWithMeteredMinimum != null + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isNewPlanMatrixWithDisplayName(): Boolean = newPlanMatrixWithDisplayName != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isNewPlanBulkWithProration(): Boolean = newPlanBulkWithProration != null + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isNewPlanGroupedTieredPackage(): Boolean = newPlanGroupedTieredPackage != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun isNewPlanMaxGroupTieredPackage(): Boolean = newPlanMaxGroupTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isNewPlanScalableMatrixWithUnitPricing(): Boolean = - newPlanScalableMatrixWithUnitPricing != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isNewPlanScalableMatrixWithTieredPricing(): Boolean = - newPlanScalableMatrixWithTieredPricing != null + fun isScalableMatrixWithTieredPricing(): Boolean = scalableMatrixWithTieredPricing != null - fun isNewPlanCumulativeGroupedBulk(): Boolean = newPlanCumulativeGroupedBulk != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun asNewPlanUnit(): NewPlanUnitPrice = newPlanUnit.getOrThrow("newPlanUnit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asNewPlanPackage(): NewPlanPackagePrice = newPlanPackage.getOrThrow("newPlanPackage") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asNewPlanMatrix(): NewPlanMatrixPrice = newPlanMatrix.getOrThrow("newPlanMatrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asNewPlanTiered(): NewPlanTieredPrice = newPlanTiered.getOrThrow("newPlanTiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asNewPlanTieredBps(): NewPlanTieredBpsPrice = - newPlanTieredBps.getOrThrow("newPlanTieredBps") + fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - fun asNewPlanBps(): NewPlanBpsPrice = newPlanBps.getOrThrow("newPlanBps") + fun asBps(): Bps = bps.getOrThrow("bps") - fun asNewPlanBulkBps(): NewPlanBulkBpsPrice = newPlanBulkBps.getOrThrow("newPlanBulkBps") + fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") - fun asNewPlanBulk(): NewPlanBulkPrice = newPlanBulk.getOrThrow("newPlanBulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") - fun asNewPlanThresholdTotalAmount(): NewPlanThresholdTotalAmountPrice = - newPlanThresholdTotalAmount.getOrThrow("newPlanThresholdTotalAmount") + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asNewPlanTieredPackage(): NewPlanTieredPackagePrice = - newPlanTieredPackage.getOrThrow("newPlanTieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asNewPlanTieredWithMinimum(): NewPlanTieredWithMinimumPrice = - newPlanTieredWithMinimum.getOrThrow("newPlanTieredWithMinimum") + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asNewPlanUnitWithPercent(): NewPlanUnitWithPercentPrice = - newPlanUnitWithPercent.getOrThrow("newPlanUnitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asNewPlanPackageWithAllocation(): NewPlanPackageWithAllocationPrice = - newPlanPackageWithAllocation.getOrThrow("newPlanPackageWithAllocation") + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") - fun asNewPlanTierWithProration(): NewPlanTierWithProrationPrice = - newPlanTierWithProration.getOrThrow("newPlanTierWithProration") + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") - fun asNewPlanUnitWithProration(): NewPlanUnitWithProrationPrice = - newPlanUnitWithProration.getOrThrow("newPlanUnitWithProration") + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") - fun asNewPlanGroupedAllocation(): NewPlanGroupedAllocationPrice = - newPlanGroupedAllocation.getOrThrow("newPlanGroupedAllocation") + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") - fun asNewPlanGroupedWithProratedMinimum(): NewPlanGroupedWithProratedMinimumPrice = - newPlanGroupedWithProratedMinimum.getOrThrow("newPlanGroupedWithProratedMinimum") + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asNewPlanGroupedWithMeteredMinimum(): NewPlanGroupedWithMeteredMinimumPrice = - newPlanGroupedWithMeteredMinimum.getOrThrow("newPlanGroupedWithMeteredMinimum") + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - fun asNewPlanMatrixWithDisplayName(): NewPlanMatrixWithDisplayNamePrice = - newPlanMatrixWithDisplayName.getOrThrow("newPlanMatrixWithDisplayName") + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asNewPlanBulkWithProration(): NewPlanBulkWithProrationPrice = - newPlanBulkWithProration.getOrThrow("newPlanBulkWithProration") + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") - fun asNewPlanGroupedTieredPackage(): NewPlanGroupedTieredPackagePrice = - newPlanGroupedTieredPackage.getOrThrow("newPlanGroupedTieredPackage") + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asNewPlanMaxGroupTieredPackage(): NewPlanMaxGroupTieredPackagePrice = - newPlanMaxGroupTieredPackage.getOrThrow("newPlanMaxGroupTieredPackage") + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asNewPlanScalableMatrixWithUnitPricing(): NewPlanScalableMatrixWithUnitPricingPrice = - newPlanScalableMatrixWithUnitPricing.getOrThrow("newPlanScalableMatrixWithUnitPricing") + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asNewPlanScalableMatrixWithTieredPricing(): - NewPlanScalableMatrixWithTieredPricingPrice = - newPlanScalableMatrixWithTieredPricing.getOrThrow( - "newPlanScalableMatrixWithTieredPricing" - ) + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asNewPlanCumulativeGroupedBulk(): NewPlanCumulativeGroupedBulkPrice = - newPlanCumulativeGroupedBulk.getOrThrow("newPlanCumulativeGroupedBulk") + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newPlanUnit != null -> visitor.visitNewPlanUnit(newPlanUnit) - newPlanPackage != null -> visitor.visitNewPlanPackage(newPlanPackage) - newPlanMatrix != null -> visitor.visitNewPlanMatrix(newPlanMatrix) - newPlanTiered != null -> visitor.visitNewPlanTiered(newPlanTiered) - newPlanTieredBps != null -> visitor.visitNewPlanTieredBps(newPlanTieredBps) - newPlanBps != null -> visitor.visitNewPlanBps(newPlanBps) - newPlanBulkBps != null -> visitor.visitNewPlanBulkBps(newPlanBulkBps) - newPlanBulk != null -> visitor.visitNewPlanBulk(newPlanBulk) - newPlanThresholdTotalAmount != null -> - visitor.visitNewPlanThresholdTotalAmount(newPlanThresholdTotalAmount) - newPlanTieredPackage != null -> - visitor.visitNewPlanTieredPackage(newPlanTieredPackage) - newPlanTieredWithMinimum != null -> - visitor.visitNewPlanTieredWithMinimum(newPlanTieredWithMinimum) - newPlanUnitWithPercent != null -> - visitor.visitNewPlanUnitWithPercent(newPlanUnitWithPercent) - newPlanPackageWithAllocation != null -> - visitor.visitNewPlanPackageWithAllocation(newPlanPackageWithAllocation) - newPlanTierWithProration != null -> - visitor.visitNewPlanTierWithProration(newPlanTierWithProration) - newPlanUnitWithProration != null -> - visitor.visitNewPlanUnitWithProration(newPlanUnitWithProration) - newPlanGroupedAllocation != null -> - visitor.visitNewPlanGroupedAllocation(newPlanGroupedAllocation) - newPlanGroupedWithProratedMinimum != null -> - visitor.visitNewPlanGroupedWithProratedMinimum( - newPlanGroupedWithProratedMinimum - ) - newPlanGroupedWithMeteredMinimum != null -> - visitor.visitNewPlanGroupedWithMeteredMinimum(newPlanGroupedWithMeteredMinimum) - newPlanMatrixWithDisplayName != null -> - visitor.visitNewPlanMatrixWithDisplayName(newPlanMatrixWithDisplayName) - newPlanBulkWithProration != null -> - visitor.visitNewPlanBulkWithProration(newPlanBulkWithProration) - newPlanGroupedTieredPackage != null -> - visitor.visitNewPlanGroupedTieredPackage(newPlanGroupedTieredPackage) - newPlanMaxGroupTieredPackage != null -> - visitor.visitNewPlanMaxGroupTieredPackage(newPlanMaxGroupTieredPackage) - newPlanScalableMatrixWithUnitPricing != null -> - visitor.visitNewPlanScalableMatrixWithUnitPricing( - newPlanScalableMatrixWithUnitPricing - ) - newPlanScalableMatrixWithTieredPricing != null -> - visitor.visitNewPlanScalableMatrixWithTieredPricing( - newPlanScalableMatrixWithTieredPricing - ) - newPlanCumulativeGroupedBulk != null -> - visitor.visitNewPlanCumulativeGroupedBulk(newPlanCumulativeGroupedBulk) + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + tieredBps != null -> visitor.visitTieredBps(tieredBps) + bps != null -> visitor.visitBps(bps) + bulkBps != null -> visitor.visitBulkBps(bulkBps) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) else -> visitor.unknown(_json) } @@ -1617,141 +1498,127 @@ private constructor( } accept( - object : Visitor { - override fun visitNewPlanUnit(newPlanUnit: NewPlanUnitPrice) { - newPlanUnit.validate() + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() } - override fun visitNewPlanPackage(newPlanPackage: NewPlanPackagePrice) { - newPlanPackage.validate() + override fun visitPackage(package_: Package) { + package_.validate() } - override fun visitNewPlanMatrix(newPlanMatrix: NewPlanMatrixPrice) { - newPlanMatrix.validate() + override fun visitMatrix(matrix: Matrix) { + matrix.validate() } - override fun visitNewPlanTiered(newPlanTiered: NewPlanTieredPrice) { - newPlanTiered.validate() + override fun visitTiered(tiered: Tiered) { + tiered.validate() } - override fun visitNewPlanTieredBps(newPlanTieredBps: NewPlanTieredBpsPrice) { - newPlanTieredBps.validate() + override fun visitTieredBps(tieredBps: TieredBps) { + tieredBps.validate() } - override fun visitNewPlanBps(newPlanBps: NewPlanBpsPrice) { - newPlanBps.validate() + override fun visitBps(bps: Bps) { + bps.validate() } - override fun visitNewPlanBulkBps(newPlanBulkBps: NewPlanBulkBpsPrice) { - newPlanBulkBps.validate() + override fun visitBulkBps(bulkBps: BulkBps) { + bulkBps.validate() } - override fun visitNewPlanBulk(newPlanBulk: NewPlanBulkPrice) { - newPlanBulk.validate() + override fun visitBulk(bulk: Bulk) { + bulk.validate() } - override fun visitNewPlanThresholdTotalAmount( - newPlanThresholdTotalAmount: NewPlanThresholdTotalAmountPrice + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount ) { - newPlanThresholdTotalAmount.validate() + thresholdTotalAmount.validate() } - override fun visitNewPlanTieredPackage( - newPlanTieredPackage: NewPlanTieredPackagePrice - ) { - newPlanTieredPackage.validate() + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() } - override fun visitNewPlanTieredWithMinimum( - newPlanTieredWithMinimum: NewPlanTieredWithMinimumPrice - ) { - newPlanTieredWithMinimum.validate() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() } - override fun visitNewPlanUnitWithPercent( - newPlanUnitWithPercent: NewPlanUnitWithPercentPrice - ) { - newPlanUnitWithPercent.validate() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() } - override fun visitNewPlanPackageWithAllocation( - newPlanPackageWithAllocation: NewPlanPackageWithAllocationPrice + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation ) { - newPlanPackageWithAllocation.validate() + packageWithAllocation.validate() } - override fun visitNewPlanTierWithProration( - newPlanTierWithProration: NewPlanTierWithProrationPrice + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration ) { - newPlanTierWithProration.validate() + tieredWithProration.validate() } - override fun visitNewPlanUnitWithProration( - newPlanUnitWithProration: NewPlanUnitWithProrationPrice - ) { - newPlanUnitWithProration.validate() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() } - override fun visitNewPlanGroupedAllocation( - newPlanGroupedAllocation: NewPlanGroupedAllocationPrice - ) { - newPlanGroupedAllocation.validate() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() } - override fun visitNewPlanGroupedWithProratedMinimum( - newPlanGroupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { - newPlanGroupedWithProratedMinimum.validate() + groupedWithProratedMinimum.validate() } - override fun visitNewPlanGroupedWithMeteredMinimum( - newPlanGroupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { - newPlanGroupedWithMeteredMinimum.validate() + groupedWithMeteredMinimum.validate() } - override fun visitNewPlanMatrixWithDisplayName( - newPlanMatrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName ) { - newPlanMatrixWithDisplayName.validate() + matrixWithDisplayName.validate() } - override fun visitNewPlanBulkWithProration( - newPlanBulkWithProration: NewPlanBulkWithProrationPrice - ) { - newPlanBulkWithProration.validate() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() } - override fun visitNewPlanGroupedTieredPackage( - newPlanGroupedTieredPackage: NewPlanGroupedTieredPackagePrice + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage ) { - newPlanGroupedTieredPackage.validate() + groupedTieredPackage.validate() } - override fun visitNewPlanMaxGroupTieredPackage( - newPlanMaxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage ) { - newPlanMaxGroupTieredPackage.validate() + maxGroupTieredPackage.validate() } - override fun visitNewPlanScalableMatrixWithUnitPricing( - newPlanScalableMatrixWithUnitPricing: - NewPlanScalableMatrixWithUnitPricingPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { - newPlanScalableMatrixWithUnitPricing.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitNewPlanScalableMatrixWithTieredPricing( - newPlanScalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { - newPlanScalableMatrixWithTieredPricing.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitNewPlanCumulativeGroupedBulk( - newPlanCumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk ) { - newPlanCumulativeGroupedBulk.validate() + cumulativeGroupedBulk.validate() } } ) @@ -1776,99 +1643,83 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewPlanUnit(newPlanUnit: NewPlanUnitPrice) = - newPlanUnit.validity() + override fun visitUnit(unit: Unit) = unit.validity() - override fun visitNewPlanPackage(newPlanPackage: NewPlanPackagePrice) = - newPlanPackage.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitNewPlanMatrix(newPlanMatrix: NewPlanMatrixPrice) = - newPlanMatrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() - override fun visitNewPlanTiered(newPlanTiered: NewPlanTieredPrice) = - newPlanTiered.validity() + override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitNewPlanTieredBps(newPlanTieredBps: NewPlanTieredBpsPrice) = - newPlanTieredBps.validity() + override fun visitTieredBps(tieredBps: TieredBps) = tieredBps.validity() - override fun visitNewPlanBps(newPlanBps: NewPlanBpsPrice) = - newPlanBps.validity() + override fun visitBps(bps: Bps) = bps.validity() - override fun visitNewPlanBulkBps(newPlanBulkBps: NewPlanBulkBpsPrice) = - newPlanBulkBps.validity() + override fun visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() - override fun visitNewPlanBulk(newPlanBulk: NewPlanBulkPrice) = - newPlanBulk.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() - override fun visitNewPlanThresholdTotalAmount( - newPlanThresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = newPlanThresholdTotalAmount.validity() + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() - override fun visitNewPlanTieredPackage( - newPlanTieredPackage: NewPlanTieredPackagePrice - ) = newPlanTieredPackage.validity() + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() - override fun visitNewPlanTieredWithMinimum( - newPlanTieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = newPlanTieredWithMinimum.validity() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() - override fun visitNewPlanUnitWithPercent( - newPlanUnitWithPercent: NewPlanUnitWithPercentPrice - ) = newPlanUnitWithPercent.validity() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() - override fun visitNewPlanPackageWithAllocation( - newPlanPackageWithAllocation: NewPlanPackageWithAllocationPrice - ) = newPlanPackageWithAllocation.validity() + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() - override fun visitNewPlanTierWithProration( - newPlanTierWithProration: NewPlanTierWithProrationPrice - ) = newPlanTierWithProration.validity() + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() - override fun visitNewPlanUnitWithProration( - newPlanUnitWithProration: NewPlanUnitWithProrationPrice - ) = newPlanUnitWithProration.validity() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() - override fun visitNewPlanGroupedAllocation( - newPlanGroupedAllocation: NewPlanGroupedAllocationPrice - ) = newPlanGroupedAllocation.validity() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() - override fun visitNewPlanGroupedWithProratedMinimum( - newPlanGroupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = newPlanGroupedWithProratedMinimum.validity() + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() - override fun visitNewPlanGroupedWithMeteredMinimum( - newPlanGroupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = newPlanGroupedWithMeteredMinimum.validity() + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() - override fun visitNewPlanMatrixWithDisplayName( - newPlanMatrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = newPlanMatrixWithDisplayName.validity() + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() - override fun visitNewPlanBulkWithProration( - newPlanBulkWithProration: NewPlanBulkWithProrationPrice - ) = newPlanBulkWithProration.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() - override fun visitNewPlanGroupedTieredPackage( - newPlanGroupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = newPlanGroupedTieredPackage.validity() + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() - override fun visitNewPlanMaxGroupTieredPackage( - newPlanMaxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = newPlanMaxGroupTieredPackage.validity() + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() - override fun visitNewPlanScalableMatrixWithUnitPricing( - newPlanScalableMatrixWithUnitPricing: - NewPlanScalableMatrixWithUnitPricingPrice - ) = newPlanScalableMatrixWithUnitPricing.validity() + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() - override fun visitNewPlanScalableMatrixWithTieredPricing( - newPlanScalableMatrixWithTieredPricing: - NewPlanScalableMatrixWithTieredPricingPrice - ) = newPlanScalableMatrixWithTieredPricing.validity() + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() - override fun visitNewPlanCumulativeGroupedBulk( - newPlanCumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = newPlanCumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1879,258 +1730,199 @@ private constructor( return true } - return /* spotless:off */ other is Price && newPlanUnit == other.newPlanUnit && newPlanPackage == other.newPlanPackage && newPlanMatrix == other.newPlanMatrix && newPlanTiered == other.newPlanTiered && newPlanTieredBps == other.newPlanTieredBps && newPlanBps == other.newPlanBps && newPlanBulkBps == other.newPlanBulkBps && newPlanBulk == other.newPlanBulk && newPlanThresholdTotalAmount == other.newPlanThresholdTotalAmount && newPlanTieredPackage == other.newPlanTieredPackage && newPlanTieredWithMinimum == other.newPlanTieredWithMinimum && newPlanUnitWithPercent == other.newPlanUnitWithPercent && newPlanPackageWithAllocation == other.newPlanPackageWithAllocation && newPlanTierWithProration == other.newPlanTierWithProration && newPlanUnitWithProration == other.newPlanUnitWithProration && newPlanGroupedAllocation == other.newPlanGroupedAllocation && newPlanGroupedWithProratedMinimum == other.newPlanGroupedWithProratedMinimum && newPlanGroupedWithMeteredMinimum == other.newPlanGroupedWithMeteredMinimum && newPlanMatrixWithDisplayName == other.newPlanMatrixWithDisplayName && newPlanBulkWithProration == other.newPlanBulkWithProration && newPlanGroupedTieredPackage == other.newPlanGroupedTieredPackage && newPlanMaxGroupTieredPackage == other.newPlanMaxGroupTieredPackage && newPlanScalableMatrixWithUnitPricing == other.newPlanScalableMatrixWithUnitPricing && newPlanScalableMatrixWithTieredPricing == other.newPlanScalableMatrixWithTieredPricing && newPlanCumulativeGroupedBulk == other.newPlanCumulativeGroupedBulk /* spotless:on */ + 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 /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newPlanUnit, newPlanPackage, newPlanMatrix, newPlanTiered, newPlanTieredBps, newPlanBps, newPlanBulkBps, newPlanBulk, newPlanThresholdTotalAmount, newPlanTieredPackage, newPlanTieredWithMinimum, newPlanUnitWithPercent, newPlanPackageWithAllocation, newPlanTierWithProration, newPlanUnitWithProration, newPlanGroupedAllocation, newPlanGroupedWithProratedMinimum, newPlanGroupedWithMeteredMinimum, newPlanMatrixWithDisplayName, newPlanBulkWithProration, newPlanGroupedTieredPackage, newPlanMaxGroupTieredPackage, newPlanScalableMatrixWithUnitPricing, newPlanScalableMatrixWithTieredPricing, newPlanCumulativeGroupedBulk) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, groupedWithMeteredMinimum, matrixWithDisplayName, bulkWithProration, groupedTieredPackage, maxGroupTieredPackage, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk) /* spotless:on */ override fun toString(): String = when { - newPlanUnit != null -> "Price{newPlanUnit=$newPlanUnit}" - newPlanPackage != null -> "Price{newPlanPackage=$newPlanPackage}" - newPlanMatrix != null -> "Price{newPlanMatrix=$newPlanMatrix}" - newPlanTiered != null -> "Price{newPlanTiered=$newPlanTiered}" - newPlanTieredBps != null -> "Price{newPlanTieredBps=$newPlanTieredBps}" - newPlanBps != null -> "Price{newPlanBps=$newPlanBps}" - newPlanBulkBps != null -> "Price{newPlanBulkBps=$newPlanBulkBps}" - newPlanBulk != null -> "Price{newPlanBulk=$newPlanBulk}" - newPlanThresholdTotalAmount != null -> - "Price{newPlanThresholdTotalAmount=$newPlanThresholdTotalAmount}" - newPlanTieredPackage != null -> "Price{newPlanTieredPackage=$newPlanTieredPackage}" - newPlanTieredWithMinimum != null -> - "Price{newPlanTieredWithMinimum=$newPlanTieredWithMinimum}" - newPlanUnitWithPercent != null -> - "Price{newPlanUnitWithPercent=$newPlanUnitWithPercent}" - newPlanPackageWithAllocation != null -> - "Price{newPlanPackageWithAllocation=$newPlanPackageWithAllocation}" - newPlanTierWithProration != null -> - "Price{newPlanTierWithProration=$newPlanTierWithProration}" - newPlanUnitWithProration != null -> - "Price{newPlanUnitWithProration=$newPlanUnitWithProration}" - newPlanGroupedAllocation != null -> - "Price{newPlanGroupedAllocation=$newPlanGroupedAllocation}" - newPlanGroupedWithProratedMinimum != null -> - "Price{newPlanGroupedWithProratedMinimum=$newPlanGroupedWithProratedMinimum}" - newPlanGroupedWithMeteredMinimum != null -> - "Price{newPlanGroupedWithMeteredMinimum=$newPlanGroupedWithMeteredMinimum}" - newPlanMatrixWithDisplayName != null -> - "Price{newPlanMatrixWithDisplayName=$newPlanMatrixWithDisplayName}" - newPlanBulkWithProration != null -> - "Price{newPlanBulkWithProration=$newPlanBulkWithProration}" - newPlanGroupedTieredPackage != null -> - "Price{newPlanGroupedTieredPackage=$newPlanGroupedTieredPackage}" - newPlanMaxGroupTieredPackage != null -> - "Price{newPlanMaxGroupTieredPackage=$newPlanMaxGroupTieredPackage}" - newPlanScalableMatrixWithUnitPricing != null -> - "Price{newPlanScalableMatrixWithUnitPricing=$newPlanScalableMatrixWithUnitPricing}" - newPlanScalableMatrixWithTieredPricing != null -> - "Price{newPlanScalableMatrixWithTieredPricing=$newPlanScalableMatrixWithTieredPricing}" - newPlanCumulativeGroupedBulk != null -> - "Price{newPlanCumulativeGroupedBulk=$newPlanCumulativeGroupedBulk}" + 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}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } companion object { - @JvmStatic - fun ofNewPlanUnit(newPlanUnit: NewPlanUnitPrice) = Price(newPlanUnit = newPlanUnit) + @JvmStatic fun ofUnit(unit: Unit) = Price(unit = unit) - @JvmStatic - fun ofNewPlanPackage(newPlanPackage: NewPlanPackagePrice) = - Price(newPlanPackage = newPlanPackage) + @JvmStatic fun ofPackage(package_: Package) = Price(package_ = package_) - @JvmStatic - fun ofNewPlanMatrix(newPlanMatrix: NewPlanMatrixPrice) = - Price(newPlanMatrix = newPlanMatrix) + @JvmStatic fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) - @JvmStatic - fun ofNewPlanTiered(newPlanTiered: NewPlanTieredPrice) = - Price(newPlanTiered = newPlanTiered) + @JvmStatic fun ofTiered(tiered: Tiered) = Price(tiered = tiered) - @JvmStatic - fun ofNewPlanTieredBps(newPlanTieredBps: NewPlanTieredBpsPrice) = - Price(newPlanTieredBps = newPlanTieredBps) + @JvmStatic fun ofTieredBps(tieredBps: TieredBps) = Price(tieredBps = tieredBps) - @JvmStatic - fun ofNewPlanBps(newPlanBps: NewPlanBpsPrice) = Price(newPlanBps = newPlanBps) + @JvmStatic fun ofBps(bps: Bps) = Price(bps = bps) - @JvmStatic - fun ofNewPlanBulkBps(newPlanBulkBps: NewPlanBulkBpsPrice) = - Price(newPlanBulkBps = newPlanBulkBps) + @JvmStatic fun ofBulkBps(bulkBps: BulkBps) = Price(bulkBps = bulkBps) - @JvmStatic - fun ofNewPlanBulk(newPlanBulk: NewPlanBulkPrice) = Price(newPlanBulk = newPlanBulk) + @JvmStatic fun ofBulk(bulk: Bulk) = Price(bulk = bulk) @JvmStatic - fun ofNewPlanThresholdTotalAmount( - newPlanThresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ) = Price(newPlanThresholdTotalAmount = newPlanThresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + Price(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofNewPlanTieredPackage(newPlanTieredPackage: NewPlanTieredPackagePrice) = - Price(newPlanTieredPackage = newPlanTieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = Price(tieredPackage = tieredPackage) @JvmStatic - fun ofNewPlanTieredWithMinimum( - newPlanTieredWithMinimum: NewPlanTieredWithMinimumPrice - ) = Price(newPlanTieredWithMinimum = newPlanTieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofNewPlanUnitWithPercent(newPlanUnitWithPercent: NewPlanUnitWithPercentPrice) = - Price(newPlanUnitWithPercent = newPlanUnitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + Price(unitWithPercent = unitWithPercent) @JvmStatic - fun ofNewPlanPackageWithAllocation( - newPlanPackageWithAllocation: NewPlanPackageWithAllocationPrice - ) = Price(newPlanPackageWithAllocation = newPlanPackageWithAllocation) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofNewPlanTierWithProration( - newPlanTierWithProration: NewPlanTierWithProrationPrice - ) = Price(newPlanTierWithProration = newPlanTierWithProration) + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) @JvmStatic - fun ofNewPlanUnitWithProration( - newPlanUnitWithProration: NewPlanUnitWithProrationPrice - ) = Price(newPlanUnitWithProration = newPlanUnitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + Price(unitWithProration = unitWithProration) @JvmStatic - fun ofNewPlanGroupedAllocation( - newPlanGroupedAllocation: NewPlanGroupedAllocationPrice - ) = Price(newPlanGroupedAllocation = newPlanGroupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + Price(groupedAllocation = groupedAllocation) @JvmStatic - fun ofNewPlanGroupedWithProratedMinimum( - newPlanGroupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice - ) = Price(newPlanGroupedWithProratedMinimum = newPlanGroupedWithProratedMinimum) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofNewPlanGroupedWithMeteredMinimum( - newPlanGroupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice - ) = Price(newPlanGroupedWithMeteredMinimum = newPlanGroupedWithMeteredMinimum) + fun ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofNewPlanMatrixWithDisplayName( - newPlanMatrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ) = Price(newPlanMatrixWithDisplayName = newPlanMatrixWithDisplayName) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofNewPlanBulkWithProration( - newPlanBulkWithProration: NewPlanBulkWithProrationPrice - ) = Price(newPlanBulkWithProration = newPlanBulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + Price(bulkWithProration = bulkWithProration) @JvmStatic - fun ofNewPlanGroupedTieredPackage( - newPlanGroupedTieredPackage: NewPlanGroupedTieredPackagePrice - ) = Price(newPlanGroupedTieredPackage = newPlanGroupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + Price(groupedTieredPackage = groupedTieredPackage) @JvmStatic - fun ofNewPlanMaxGroupTieredPackage( - newPlanMaxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ) = Price(newPlanMaxGroupTieredPackage = newPlanMaxGroupTieredPackage) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + Price(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic - fun ofNewPlanScalableMatrixWithUnitPricing( - newPlanScalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice - ) = Price(newPlanScalableMatrixWithUnitPricing = newPlanScalableMatrixWithUnitPricing) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic - fun ofNewPlanScalableMatrixWithTieredPricing( - newPlanScalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice - ) = - Price( - newPlanScalableMatrixWithTieredPricing = newPlanScalableMatrixWithTieredPricing - ) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofNewPlanCumulativeGroupedBulk( - newPlanCumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ) = Price(newPlanCumulativeGroupedBulk = newPlanCumulativeGroupedBulk) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + Price(cumulativeGroupedBulk = cumulativeGroupedBulk) } /** An interface that defines how to map each variant of [Price] to a value of type [T]. */ interface Visitor { - fun visitNewPlanUnit(newPlanUnit: NewPlanUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitNewPlanPackage(newPlanPackage: NewPlanPackagePrice): T + fun visitPackage(package_: Package): T - fun visitNewPlanMatrix(newPlanMatrix: NewPlanMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitNewPlanTiered(newPlanTiered: NewPlanTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitNewPlanTieredBps(newPlanTieredBps: NewPlanTieredBpsPrice): T + fun visitTieredBps(tieredBps: TieredBps): T - fun visitNewPlanBps(newPlanBps: NewPlanBpsPrice): T + fun visitBps(bps: Bps): T - fun visitNewPlanBulkBps(newPlanBulkBps: NewPlanBulkBpsPrice): T + fun visitBulkBps(bulkBps: BulkBps): T - fun visitNewPlanBulk(newPlanBulk: NewPlanBulkPrice): T + fun visitBulk(bulk: Bulk): T - fun visitNewPlanThresholdTotalAmount( - newPlanThresholdTotalAmount: NewPlanThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitNewPlanTieredPackage(newPlanTieredPackage: NewPlanTieredPackagePrice): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitNewPlanTieredWithMinimum( - newPlanTieredWithMinimum: NewPlanTieredWithMinimumPrice - ): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitNewPlanUnitWithPercent(newPlanUnitWithPercent: NewPlanUnitWithPercentPrice): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitNewPlanPackageWithAllocation( - newPlanPackageWithAllocation: NewPlanPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitNewPlanTierWithProration( - newPlanTierWithProration: NewPlanTierWithProrationPrice - ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitNewPlanUnitWithProration( - newPlanUnitWithProration: NewPlanUnitWithProrationPrice - ): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitNewPlanGroupedAllocation( - newPlanGroupedAllocation: NewPlanGroupedAllocationPrice - ): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitNewPlanGroupedWithProratedMinimum( - newPlanGroupedWithProratedMinimum: NewPlanGroupedWithProratedMinimumPrice + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T - fun visitNewPlanGroupedWithMeteredMinimum( - newPlanGroupedWithMeteredMinimum: NewPlanGroupedWithMeteredMinimumPrice + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T - fun visitNewPlanMatrixWithDisplayName( - newPlanMatrixWithDisplayName: NewPlanMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitNewPlanBulkWithProration( - newPlanBulkWithProration: NewPlanBulkWithProrationPrice - ): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T - fun visitNewPlanGroupedTieredPackage( - newPlanGroupedTieredPackage: NewPlanGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitNewPlanMaxGroupTieredPackage( - newPlanMaxGroupTieredPackage: NewPlanMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T - fun visitNewPlanScalableMatrixWithUnitPricing( - newPlanScalableMatrixWithUnitPricing: NewPlanScalableMatrixWithUnitPricingPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T - fun visitNewPlanScalableMatrixWithTieredPricing( - newPlanScalableMatrixWithTieredPricing: NewPlanScalableMatrixWithTieredPricingPrice + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitNewPlanCumulativeGroupedBulk( - newPlanCumulativeGroupedBulk: NewPlanCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -2156,160 +1948,132 @@ private constructor( when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(newPlanUnit = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) } ?: Price(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(newPlanPackage = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(package_ = it, _json = json) } ?: Price(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(newPlanMatrix = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) } ?: Price(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(newPlanTiered = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) } ?: Price(_json = json) } "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(newPlanTieredBps = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredBps = it, _json = json) } ?: Price(_json = json) } "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(newPlanBps = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bps = it, _json = json) } ?: Price(_json = json) } "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(newPlanBulkBps = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkBps = it, _json = json) } ?: Price(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(newPlanBulk = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) } ?: Price(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newPlanThresholdTotalAmount = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(thresholdTotalAmount = it, _json = json) + } ?: Price(_json = json) } "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newPlanTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredPackage = it, _json = json) + } ?: Price(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newPlanTieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredWithMinimum = it, _json = json) + } ?: Price(_json = json) } "unit_with_percent" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newPlanUnitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithPercent = it, _json = json) + } ?: Price(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newPlanPackageWithAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(packageWithAllocation = it, _json = json) + } ?: Price(_json = json) } "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newPlanTierWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredWithProration = it, _json = json) + } ?: Price(_json = json) } "unit_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newPlanUnitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_allocation" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newPlanGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedAllocation = it, _json = json) + } ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newPlanGroupedWithProratedMinimum = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newPlanGroupedWithMeteredMinimum = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } ?: Price(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newPlanMatrixWithDisplayName = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrixWithDisplayName = it, _json = json) + } ?: Price(_json = json) } "bulk_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newPlanBulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newPlanGroupedTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedTieredPackage = it, _json = json) + } ?: Price(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newPlanMaxGroupTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(maxGroupTieredPackage = it, _json = json) + } ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newPlanScalableMatrixWithUnitPricing = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { - Price(newPlanScalableMatrixWithTieredPricing = it, _json = json) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newPlanCumulativeGroupedBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(cumulativeGroupedBulk = it, _json = json) + } ?: Price(_json = json) } } @@ -2325,59 +2089,57 @@ private constructor( provider: SerializerProvider, ) { when { - value.newPlanUnit != null -> generator.writeObject(value.newPlanUnit) - value.newPlanPackage != null -> generator.writeObject(value.newPlanPackage) - value.newPlanMatrix != null -> generator.writeObject(value.newPlanMatrix) - value.newPlanTiered != null -> generator.writeObject(value.newPlanTiered) - value.newPlanTieredBps != null -> generator.writeObject(value.newPlanTieredBps) - value.newPlanBps != null -> generator.writeObject(value.newPlanBps) - value.newPlanBulkBps != null -> generator.writeObject(value.newPlanBulkBps) - value.newPlanBulk != null -> generator.writeObject(value.newPlanBulk) - value.newPlanThresholdTotalAmount != null -> - generator.writeObject(value.newPlanThresholdTotalAmount) - value.newPlanTieredPackage != null -> - generator.writeObject(value.newPlanTieredPackage) - value.newPlanTieredWithMinimum != null -> - generator.writeObject(value.newPlanTieredWithMinimum) - value.newPlanUnitWithPercent != null -> - generator.writeObject(value.newPlanUnitWithPercent) - value.newPlanPackageWithAllocation != null -> - generator.writeObject(value.newPlanPackageWithAllocation) - value.newPlanTierWithProration != null -> - generator.writeObject(value.newPlanTierWithProration) - value.newPlanUnitWithProration != null -> - generator.writeObject(value.newPlanUnitWithProration) - value.newPlanGroupedAllocation != null -> - generator.writeObject(value.newPlanGroupedAllocation) - value.newPlanGroupedWithProratedMinimum != null -> - generator.writeObject(value.newPlanGroupedWithProratedMinimum) - value.newPlanGroupedWithMeteredMinimum != null -> - generator.writeObject(value.newPlanGroupedWithMeteredMinimum) - value.newPlanMatrixWithDisplayName != null -> - generator.writeObject(value.newPlanMatrixWithDisplayName) - value.newPlanBulkWithProration != null -> - generator.writeObject(value.newPlanBulkWithProration) - value.newPlanGroupedTieredPackage != null -> - generator.writeObject(value.newPlanGroupedTieredPackage) - value.newPlanMaxGroupTieredPackage != null -> - generator.writeObject(value.newPlanMaxGroupTieredPackage) - value.newPlanScalableMatrixWithUnitPricing != null -> - generator.writeObject(value.newPlanScalableMatrixWithUnitPricing) - value.newPlanScalableMatrixWithTieredPricing != null -> - generator.writeObject(value.newPlanScalableMatrixWithTieredPricing) - value.newPlanCumulativeGroupedBulk != null -> - generator.writeObject(value.newPlanCumulativeGroupedBulk) + 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._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - class NewPlanUnitPrice + class Unit private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitConfig: JsonField, private val billableMetricId: JsonField, @@ -2401,9 +2163,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("unit_config") @ExcludeMissing @@ -2477,11 +2237,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -2605,16 +2369,6 @@ private constructor( */ @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]. * @@ -2747,13 +2501,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewPlanUnitPrice]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` @@ -2761,12 +2514,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanUnitPrice]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -2784,23 +2537,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanUnitPrice: NewPlanUnitPrice) = apply { - cadence = newPlanUnitPrice.cadence - itemId = newPlanUnitPrice.itemId - modelType = newPlanUnitPrice.modelType - name = newPlanUnitPrice.name - unitConfig = newPlanUnitPrice.unitConfig - billableMetricId = newPlanUnitPrice.billableMetricId - billedInAdvance = newPlanUnitPrice.billedInAdvance - billingCycleConfiguration = newPlanUnitPrice.billingCycleConfiguration - conversionRate = newPlanUnitPrice.conversionRate - currency = newPlanUnitPrice.currency - externalPriceId = newPlanUnitPrice.externalPriceId - fixedPriceQuantity = newPlanUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanUnitPrice.invoicingCycleConfiguration - metadata = newPlanUnitPrice.metadata - additionalProperties = newPlanUnitPrice.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + currency = unit.currency + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + metadata = unit.metadata + additionalProperties = unit.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -2827,18 +2580,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -3141,7 +2895,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanUnitPrice]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -3149,18 +2903,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanUnitPrice = - NewPlanUnitPrice( + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitConfig", unitConfig), billableMetricId, @@ -3179,14 +2932,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanUnitPrice = apply { + fun validate(): Unit = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitConfig().validate() billableMetricId() @@ -3220,7 +2977,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -3390,131 +3147,6 @@ private constructor( 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 UNIT = of("unit") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT - } - - /** - * 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 { - UNIT, - /** - * 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) { - UNIT -> Value.UNIT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - UNIT -> Known.UNIT - 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 UnitConfig private constructor( private val unitAmount: JsonField, @@ -4516,7 +4148,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Unit && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4526,14 +4158,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanPackagePrice + class Package private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageConfig: JsonField, private val billableMetricId: JsonField, @@ -4557,9 +4189,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("package_config") @ExcludeMissing @@ -4633,11 +4263,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -4761,16 +4395,6 @@ private constructor( */ @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]. * @@ -4903,13 +4527,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewPlanPackagePrice]. + * Returns a mutable builder for constructing an instance of [Package]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` @@ -4917,12 +4540,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanPackagePrice]. */ + /** A builder for [Package]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package") private var name: JsonField? = null private var packageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -4940,23 +4563,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanPackagePrice: NewPlanPackagePrice) = apply { - cadence = newPlanPackagePrice.cadence - itemId = newPlanPackagePrice.itemId - modelType = newPlanPackagePrice.modelType - name = newPlanPackagePrice.name - packageConfig = newPlanPackagePrice.packageConfig - billableMetricId = newPlanPackagePrice.billableMetricId - billedInAdvance = newPlanPackagePrice.billedInAdvance - billingCycleConfiguration = newPlanPackagePrice.billingCycleConfiguration - conversionRate = newPlanPackagePrice.conversionRate - currency = newPlanPackagePrice.currency - externalPriceId = newPlanPackagePrice.externalPriceId - fixedPriceQuantity = newPlanPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanPackagePrice.invoicingCycleConfiguration - metadata = newPlanPackagePrice.metadata - additionalProperties = newPlanPackagePrice.additionalProperties.toMutableMap() + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + currency = package_.currency + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + metadata = package_.metadata + additionalProperties = package_.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -4983,18 +4606,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -5298,7 +4922,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanPackagePrice]. + * Returns an immutable instance of [Package]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -5306,18 +4930,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanPackagePrice = - NewPlanPackagePrice( + fun build(): Package = + Package( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageConfig", packageConfig), billableMetricId, @@ -5336,14 +4959,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanPackagePrice = apply { + fun validate(): Package = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageConfig().validate() billableMetricId() @@ -5377,7 +5004,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -5547,131 +5174,6 @@ private constructor( 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 PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * 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 { - PACKAGE, - /** - * 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) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - 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 PackageConfig private constructor( private val packageAmount: JsonField, @@ -6723,7 +6225,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Package && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6733,15 +6235,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Package{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanMatrixPrice + class Matrix private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -6767,9 +6269,7 @@ private constructor( @JsonProperty("matrix_config") @ExcludeMissing matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -6847,11 +6347,15 @@ private constructor( fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -6978,16 +6482,6 @@ private constructor( @ExcludeMissing fun _matrixConfig(): JsonField = matrixConfig - /** - * 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]. * @@ -7110,27 +6604,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewPlanMatrixPrice]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanMatrixPrice]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -7147,23 +6640,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanMatrixPrice: NewPlanMatrixPrice) = apply { - cadence = newPlanMatrixPrice.cadence - itemId = newPlanMatrixPrice.itemId - matrixConfig = newPlanMatrixPrice.matrixConfig - modelType = newPlanMatrixPrice.modelType - name = newPlanMatrixPrice.name - billableMetricId = newPlanMatrixPrice.billableMetricId - billedInAdvance = newPlanMatrixPrice.billedInAdvance - billingCycleConfiguration = newPlanMatrixPrice.billingCycleConfiguration - conversionRate = newPlanMatrixPrice.conversionRate - currency = newPlanMatrixPrice.currency - externalPriceId = newPlanMatrixPrice.externalPriceId - fixedPriceQuantity = newPlanMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanMatrixPrice.invoicingCycleConfiguration - metadata = newPlanMatrixPrice.metadata - additionalProperties = newPlanMatrixPrice.additionalProperties.toMutableMap() + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + currency = matrix.currency + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + metadata = matrix.metadata + additionalProperties = matrix.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -7204,18 +6697,19 @@ private constructor( this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -7505,7 +6999,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanMatrixPrice]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7514,18 +7008,17 @@ private constructor( * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanMatrixPrice = - NewPlanMatrixPrice( + fun build(): Matrix = + Matrix( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -7543,7 +7036,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanMatrixPrice = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -7551,7 +7044,11 @@ private constructor( cadence().validate() itemId() matrixConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -7585,7 +7082,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -8285,131 +7782,6 @@ private constructor( "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -9241,7 +8613,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Matrix && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -9251,14 +8623,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Matrix{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanTieredPrice + class Tiered private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredConfig: JsonField, private val billableMetricId: JsonField, @@ -9282,9 +8654,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_config") @ExcludeMissing @@ -9358,11 +8728,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -9486,16 +8860,6 @@ private constructor( */ @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]. * @@ -9628,13 +8992,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewPlanTieredPrice]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` @@ -9642,12 +9005,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanTieredPrice]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered") private var name: JsonField? = null private var tieredConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -9665,23 +9028,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanTieredPrice: NewPlanTieredPrice) = apply { - cadence = newPlanTieredPrice.cadence - itemId = newPlanTieredPrice.itemId - modelType = newPlanTieredPrice.modelType - name = newPlanTieredPrice.name - tieredConfig = newPlanTieredPrice.tieredConfig - billableMetricId = newPlanTieredPrice.billableMetricId - billedInAdvance = newPlanTieredPrice.billedInAdvance - billingCycleConfiguration = newPlanTieredPrice.billingCycleConfiguration - conversionRate = newPlanTieredPrice.conversionRate - currency = newPlanTieredPrice.currency - externalPriceId = newPlanTieredPrice.externalPriceId - fixedPriceQuantity = newPlanTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanTieredPrice.invoicingCycleConfiguration - metadata = newPlanTieredPrice.metadata - additionalProperties = newPlanTieredPrice.additionalProperties.toMutableMap() + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + currency = tiered.currency + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + metadata = tiered.metadata + additionalProperties = tiered.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -9708,18 +9071,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -10023,7 +9387,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanTieredPrice]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -10031,18 +9395,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanTieredPrice = - NewPlanTieredPrice( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredConfig", tieredConfig), billableMetricId, @@ -10061,14 +9424,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanTieredPrice = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredConfig().validate() billableMetricId() @@ -10102,7 +9469,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -10272,131 +9639,6 @@ private constructor( 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 = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * 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, - /** - * 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 -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.TIERED - 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 TieredConfig private constructor( private val tiers: JsonField>, @@ -11678,7 +10920,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tiered && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -11688,14 +10930,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanTieredBpsPrice + class TieredBps private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredBpsConfig: JsonField, private val billableMetricId: JsonField, @@ -11719,9 +10961,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_bps_config") @ExcludeMissing @@ -11795,11 +11035,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -11924,16 +11168,6 @@ private constructor( */ @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]. * @@ -12066,14 +11300,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanTieredBpsPrice]. + * Returns a mutable builder for constructing an instance of [TieredBps]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` @@ -12081,12 +11313,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanTieredBpsPrice]. */ + /** A builder for [TieredBps]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_bps") private var name: JsonField? = null private var tieredBpsConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -12104,23 +11336,23 @@ private constructor( 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 - currency = newPlanTieredBpsPrice.currency - externalPriceId = newPlanTieredBpsPrice.externalPriceId - fixedPriceQuantity = newPlanTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanTieredBpsPrice.invoicingCycleConfiguration - metadata = newPlanTieredBpsPrice.metadata - additionalProperties = newPlanTieredBpsPrice.additionalProperties.toMutableMap() + internal fun from(tieredBps: TieredBps) = apply { + cadence = tieredBps.cadence + itemId = tieredBps.itemId + modelType = tieredBps.modelType + name = tieredBps.name + tieredBpsConfig = tieredBps.tieredBpsConfig + billableMetricId = tieredBps.billableMetricId + billedInAdvance = tieredBps.billedInAdvance + billingCycleConfiguration = tieredBps.billingCycleConfiguration + conversionRate = tieredBps.conversionRate + currency = tieredBps.currency + externalPriceId = tieredBps.externalPriceId + fixedPriceQuantity = tieredBps.fixedPriceQuantity + invoiceGroupingKey = tieredBps.invoiceGroupingKey + invoicingCycleConfiguration = tieredBps.invoicingCycleConfiguration + metadata = tieredBps.metadata + additionalProperties = tieredBps.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -12147,18 +11379,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -12462,7 +11695,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanTieredBpsPrice]. + * Returns an immutable instance of [TieredBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -12470,18 +11703,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanTieredBpsPrice = - NewPlanTieredBpsPrice( + fun build(): TieredBps = + TieredBps( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredBpsConfig", tieredBpsConfig), billableMetricId, @@ -12500,14 +11732,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanTieredBpsPrice = apply { + fun validate(): TieredBps = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredBpsConfig().validate() billableMetricId() @@ -12541,7 +11777,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -12711,131 +11947,6 @@ private constructor( 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() - } - class TieredBpsConfig private constructor( private val tiers: JsonField>, @@ -14165,7 +13276,7 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBps && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -14175,15 +13286,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredBps{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanBpsPrice + class Bps private constructor( private val bpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -14209,9 +13320,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -14289,11 +13398,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -14420,16 +13533,6 @@ private constructor( */ @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]. * @@ -14552,27 +13655,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewPlanBpsPrice]. + * Returns a mutable builder for constructing an instance of [Bps]. * * The following fields are required: * ```java * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanBpsPrice]. */ + /** A builder for [Bps]. */ 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 modelType: JsonValue = JsonValue.from("bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -14589,23 +13691,23 @@ private constructor( 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 - currency = newPlanBpsPrice.currency - externalPriceId = newPlanBpsPrice.externalPriceId - fixedPriceQuantity = newPlanBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanBpsPrice.invoicingCycleConfiguration - metadata = newPlanBpsPrice.metadata - additionalProperties = newPlanBpsPrice.additionalProperties.toMutableMap() + internal fun from(bps: Bps) = apply { + bpsConfig = bps.bpsConfig + cadence = bps.cadence + itemId = bps.itemId + modelType = bps.modelType + name = bps.name + billableMetricId = bps.billableMetricId + billedInAdvance = bps.billedInAdvance + billingCycleConfiguration = bps.billingCycleConfiguration + conversionRate = bps.conversionRate + currency = bps.currency + externalPriceId = bps.externalPriceId + fixedPriceQuantity = bps.fixedPriceQuantity + invoiceGroupingKey = bps.invoiceGroupingKey + invoicingCycleConfiguration = bps.invoicingCycleConfiguration + metadata = bps.metadata + additionalProperties = bps.additionalProperties.toMutableMap() } fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) @@ -14645,18 +13747,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -14946,7 +14049,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanBpsPrice]. + * Returns an immutable instance of [Bps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -14955,18 +14058,17 @@ private constructor( * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanBpsPrice = - NewPlanBpsPrice( + fun build(): Bps = + Bps( checkRequired("bpsConfig", bpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -14984,7 +14086,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanBpsPrice = apply { + fun validate(): Bps = apply { if (validated) { return@apply } @@ -14992,7 +14094,11 @@ private constructor( bpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -15026,7 +14132,7 @@ private constructor( (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -15409,131 +14515,6 @@ private constructor( 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -16365,7 +15346,7 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bps && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -16375,15 +15356,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Bps{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanBulkBpsPrice + class BulkBps private constructor( private val bulkBpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -16409,9 +15390,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -16489,11 +15468,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -16620,16 +15603,6 @@ private constructor( */ @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]. * @@ -16752,27 +15725,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewPlanBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of [BulkBps]. * * The following fields are required: * ```java * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanBulkBpsPrice]. */ + /** A builder for [BulkBps]. */ class Builder internal constructor() { private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -16789,23 +15761,23 @@ 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 - currency = newPlanBulkBpsPrice.currency - externalPriceId = newPlanBulkBpsPrice.externalPriceId - fixedPriceQuantity = newPlanBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanBulkBpsPrice.invoicingCycleConfiguration - metadata = newPlanBulkBpsPrice.metadata - additionalProperties = newPlanBulkBpsPrice.additionalProperties.toMutableMap() + internal fun from(bulkBps: BulkBps) = apply { + bulkBpsConfig = bulkBps.bulkBpsConfig + cadence = bulkBps.cadence + itemId = bulkBps.itemId + modelType = bulkBps.modelType + name = bulkBps.name + billableMetricId = bulkBps.billableMetricId + billedInAdvance = bulkBps.billedInAdvance + billingCycleConfiguration = bulkBps.billingCycleConfiguration + conversionRate = bulkBps.conversionRate + currency = bulkBps.currency + externalPriceId = bulkBps.externalPriceId + fixedPriceQuantity = bulkBps.fixedPriceQuantity + invoiceGroupingKey = bulkBps.invoiceGroupingKey + invoicingCycleConfiguration = bulkBps.invoicingCycleConfiguration + metadata = bulkBps.metadata + additionalProperties = bulkBps.additionalProperties.toMutableMap() } fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = @@ -16846,18 +15818,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -17147,7 +16120,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanBulkBpsPrice]. + * Returns an immutable instance of [BulkBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -17156,18 +16129,17 @@ private constructor( * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanBulkBpsPrice = - NewPlanBulkBpsPrice( + fun build(): BulkBps = + BulkBps( checkRequired("bulkBpsConfig", bulkBpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -17185,7 +16157,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanBulkBpsPrice = apply { + fun validate(): BulkBps = apply { if (validated) { return@apply } @@ -17193,7 +16165,11 @@ private constructor( bulkBpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -17227,7 +16203,7 @@ private constructor( (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -17849,131 +16825,6 @@ private constructor( 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 BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -18805,7 +17656,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBps && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -18815,15 +17666,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkBps{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanBulkPrice + class Bulk private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -18849,9 +17700,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -18929,11 +17778,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -19060,16 +17913,6 @@ private constructor( */ @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]. * @@ -19192,27 +18035,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewPlanBulkPrice]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanBulkPrice]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -19229,23 +18071,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanBulkPrice: NewPlanBulkPrice) = apply { - bulkConfig = newPlanBulkPrice.bulkConfig - cadence = newPlanBulkPrice.cadence - itemId = newPlanBulkPrice.itemId - modelType = newPlanBulkPrice.modelType - name = newPlanBulkPrice.name - billableMetricId = newPlanBulkPrice.billableMetricId - billedInAdvance = newPlanBulkPrice.billedInAdvance - billingCycleConfiguration = newPlanBulkPrice.billingCycleConfiguration - conversionRate = newPlanBulkPrice.conversionRate - currency = newPlanBulkPrice.currency - externalPriceId = newPlanBulkPrice.externalPriceId - fixedPriceQuantity = newPlanBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = newPlanBulkPrice.invoicingCycleConfiguration - metadata = newPlanBulkPrice.metadata - additionalProperties = newPlanBulkPrice.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + currency = bulk.currency + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + metadata = bulk.metadata + additionalProperties = bulk.additionalProperties.toMutableMap() } fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) @@ -19285,18 +18127,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -19586,7 +18429,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanBulkPrice]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -19595,18 +18438,17 @@ private constructor( * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanBulkPrice = - NewPlanBulkPrice( + fun build(): Bulk = + Bulk( checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -19624,7 +18466,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanBulkPrice = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -19632,7 +18474,11 @@ private constructor( bulkConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -19666,7 +18512,7 @@ private constructor( (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -20245,131 +19091,6 @@ private constructor( 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 BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -21201,7 +19922,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bulk && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -21211,14 +19932,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanThresholdTotalAmountPrice + class ThresholdTotalAmount private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val thresholdTotalAmountConfig: JsonField, private val billableMetricId: JsonField, @@ -21242,9 +19963,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("threshold_total_amount_config") @ExcludeMissing @@ -21319,11 +20038,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -21448,16 +20171,6 @@ private constructor( */ @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]. * @@ -21591,14 +20304,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanThresholdTotalAmountPrice]. + * Returns a mutable builder for constructing an instance of [ThresholdTotalAmount]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` @@ -21606,12 +20317,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanThresholdTotalAmountPrice]. */ + /** A builder for [ThresholdTotalAmount]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") private var name: JsonField? = null private var thresholdTotalAmountConfig: JsonField? = null @@ -21630,29 +20341,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanThresholdTotalAmountPrice: NewPlanThresholdTotalAmountPrice - ) = apply { - cadence = newPlanThresholdTotalAmountPrice.cadence - itemId = newPlanThresholdTotalAmountPrice.itemId - modelType = newPlanThresholdTotalAmountPrice.modelType - name = newPlanThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newPlanThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newPlanThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newPlanThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newPlanThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newPlanThresholdTotalAmountPrice.conversionRate - currency = newPlanThresholdTotalAmountPrice.currency - externalPriceId = newPlanThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = newPlanThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanThresholdTotalAmountPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newPlanThresholdTotalAmountPrice.metadata - additionalProperties = - newPlanThresholdTotalAmountPrice.additionalProperties.toMutableMap() + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + currency = thresholdTotalAmount.currency + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = thresholdTotalAmount.invoicingCycleConfiguration + metadata = thresholdTotalAmount.metadata + additionalProperties = thresholdTotalAmount.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -21679,18 +20384,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -21995,7 +20701,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanThresholdTotalAmountPrice]. + * Returns an immutable instance of [ThresholdTotalAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -22003,18 +20709,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanThresholdTotalAmountPrice = - NewPlanThresholdTotalAmountPrice( + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), billableMetricId, @@ -22033,14 +20738,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanThresholdTotalAmountPrice = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -22074,7 +20783,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("threshold_total_amount")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -22244,131 +20953,6 @@ private constructor( 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 THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * 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 { - THRESHOLD_TOTAL_AMOUNT, - /** - * 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) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - 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 ThresholdTotalAmountConfig @JsonCreator private constructor( @@ -23313,7 +21897,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmount && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -23323,14 +21907,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanTieredPackagePrice + class TieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredPackageConfig: JsonField, private val billableMetricId: JsonField, @@ -23354,9 +21938,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_package_config") @ExcludeMissing @@ -23430,11 +22012,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -23559,16 +22145,6 @@ private constructor( */ @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]. * @@ -23701,14 +22277,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [TieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` @@ -23716,12 +22290,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanTieredPackagePrice]. */ + /** A builder for [TieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_package") private var name: JsonField? = null private var tieredPackageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -23739,25 +22313,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanTieredPackagePrice: NewPlanTieredPackagePrice) = apply { - cadence = newPlanTieredPackagePrice.cadence - itemId = newPlanTieredPackagePrice.itemId - modelType = newPlanTieredPackagePrice.modelType - name = newPlanTieredPackagePrice.name - tieredPackageConfig = newPlanTieredPackagePrice.tieredPackageConfig - billableMetricId = newPlanTieredPackagePrice.billableMetricId - billedInAdvance = newPlanTieredPackagePrice.billedInAdvance - billingCycleConfiguration = newPlanTieredPackagePrice.billingCycleConfiguration - conversionRate = newPlanTieredPackagePrice.conversionRate - currency = newPlanTieredPackagePrice.currency - externalPriceId = newPlanTieredPackagePrice.externalPriceId - fixedPriceQuantity = newPlanTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanTieredPackagePrice.invoicingCycleConfiguration - metadata = newPlanTieredPackagePrice.metadata - additionalProperties = - newPlanTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + currency = tieredPackage.currency + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + metadata = tieredPackage.metadata + additionalProperties = tieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -23784,18 +22356,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -24100,7 +22673,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanTieredPackagePrice]. + * Returns an immutable instance of [TieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -24108,18 +22681,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanTieredPackagePrice = - NewPlanTieredPackagePrice( + fun build(): TieredPackage = + TieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredPackageConfig", tieredPackageConfig), billableMetricId, @@ -24138,14 +22710,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanTieredPackagePrice = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredPackageConfig().validate() billableMetricId() @@ -24179,7 +22755,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -24349,131 +22925,6 @@ private constructor( 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_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * 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_PACKAGE, - /** - * 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_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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_PACKAGE -> Known.TIERED_PACKAGE - 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 TieredPackageConfig @JsonCreator private constructor( @@ -25417,7 +23868,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackage && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -25427,14 +23878,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredPackage{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanTieredWithMinimumPrice + class TieredWithMinimum private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithMinimumConfig: JsonField, private val billableMetricId: JsonField, @@ -25458,9 +23909,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_minimum_config") @ExcludeMissing @@ -25534,11 +23983,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -25663,16 +24116,6 @@ private constructor( */ @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]. * @@ -25806,14 +24249,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanTieredWithMinimumPrice]. + * Returns a mutable builder for constructing an instance of [TieredWithMinimum]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` @@ -25821,12 +24262,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanTieredWithMinimumPrice]. */ + /** A builder for [TieredWithMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var tieredWithMinimumConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -25844,29 +24285,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanTieredWithMinimumPrice: NewPlanTieredWithMinimumPrice) = - apply { - cadence = newPlanTieredWithMinimumPrice.cadence - itemId = newPlanTieredWithMinimumPrice.itemId - modelType = newPlanTieredWithMinimumPrice.modelType - name = newPlanTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newPlanTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newPlanTieredWithMinimumPrice.billableMetricId - billedInAdvance = newPlanTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newPlanTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newPlanTieredWithMinimumPrice.conversionRate - currency = newPlanTieredWithMinimumPrice.currency - externalPriceId = newPlanTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = newPlanTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newPlanTieredWithMinimumPrice.metadata - additionalProperties = - newPlanTieredWithMinimumPrice.additionalProperties.toMutableMap() - } + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + currency = tieredWithMinimum.currency + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + metadata = tieredWithMinimum.metadata + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -25892,18 +24328,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -26207,7 +24644,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanTieredWithMinimumPrice]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -26215,18 +24652,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanTieredWithMinimumPrice = - NewPlanTieredWithMinimumPrice( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), billableMetricId, @@ -26245,14 +24681,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanTieredWithMinimumPrice = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithMinimumConfig().validate() billableMetricId() @@ -26286,7 +24726,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -26456,131 +24896,6 @@ private constructor( 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_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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 TieredWithMinimumConfig @JsonCreator private constructor( @@ -27524,7 +25839,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithMinimum && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -27534,14 +25849,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanUnitWithPercentPrice + class UnitWithPercent private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithPercentConfig: JsonField, private val billableMetricId: JsonField, @@ -27565,9 +25880,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_percent_config") @ExcludeMissing @@ -27641,11 +25954,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -27770,16 +26087,6 @@ private constructor( */ @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]. * @@ -27912,14 +26219,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanUnitWithPercentPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` @@ -27927,12 +26232,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanUnitWithPercentPrice]. */ + /** A builder for [UnitWithPercent]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") private var name: JsonField? = null private var unitWithPercentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -27950,28 +26255,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanUnitWithPercentPrice: NewPlanUnitWithPercentPrice) = - apply { - cadence = newPlanUnitWithPercentPrice.cadence - itemId = newPlanUnitWithPercentPrice.itemId - modelType = newPlanUnitWithPercentPrice.modelType - name = newPlanUnitWithPercentPrice.name - unitWithPercentConfig = newPlanUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newPlanUnitWithPercentPrice.billableMetricId - billedInAdvance = newPlanUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newPlanUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newPlanUnitWithPercentPrice.conversionRate - currency = newPlanUnitWithPercentPrice.currency - externalPriceId = newPlanUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newPlanUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newPlanUnitWithPercentPrice.metadata - additionalProperties = - newPlanUnitWithPercentPrice.additionalProperties.toMutableMap() - } + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + currency = unitWithPercent.currency + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + metadata = unitWithPercent.metadata + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -27997,18 +26298,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -28313,7 +26615,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanUnitWithPercentPrice]. + * Returns an immutable instance of [UnitWithPercent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -28321,18 +26623,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanUnitWithPercentPrice = - NewPlanUnitWithPercentPrice( + fun build(): UnitWithPercent = + UnitWithPercent( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithPercentConfig", unitWithPercentConfig), billableMetricId, @@ -28351,14 +26652,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanUnitWithPercentPrice = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithPercentConfig().validate() billableMetricId() @@ -28392,7 +26697,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -28562,131 +26867,6 @@ private constructor( 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 UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * 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 { - UNIT_WITH_PERCENT, - /** - * 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) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - 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 UnitWithPercentConfig @JsonCreator private constructor( @@ -29630,7 +27810,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercent && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -29640,14 +27820,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "UnitWithPercent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanPackageWithAllocationPrice + class PackageWithAllocation private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageWithAllocationConfig: JsonField, private val billableMetricId: JsonField, @@ -29671,9 +27851,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("package_with_allocation_config") @ExcludeMissing @@ -29748,11 +27926,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -29877,16 +28059,6 @@ private constructor( */ @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]. * @@ -30021,13 +28193,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPlanPackageWithAllocationPrice]. + * [PackageWithAllocation]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` @@ -30035,12 +28206,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanPackageWithAllocationPrice]. */ + /** A builder for [PackageWithAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") private var name: JsonField? = null private var packageWithAllocationConfig: JsonField? = null @@ -30059,29 +28230,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanPackageWithAllocationPrice: NewPlanPackageWithAllocationPrice - ) = apply { - cadence = newPlanPackageWithAllocationPrice.cadence - itemId = newPlanPackageWithAllocationPrice.itemId - modelType = newPlanPackageWithAllocationPrice.modelType - name = newPlanPackageWithAllocationPrice.name - packageWithAllocationConfig = - newPlanPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = newPlanPackageWithAllocationPrice.billableMetricId - billedInAdvance = newPlanPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newPlanPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newPlanPackageWithAllocationPrice.conversionRate - currency = newPlanPackageWithAllocationPrice.currency - externalPriceId = newPlanPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = newPlanPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanPackageWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newPlanPackageWithAllocationPrice.metadata - additionalProperties = - newPlanPackageWithAllocationPrice.additionalProperties.toMutableMap() + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + currency = packageWithAllocation.currency + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = packageWithAllocation.invoicingCycleConfiguration + metadata = packageWithAllocation.metadata + additionalProperties = packageWithAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -30108,18 +28273,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -30424,7 +28590,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanPackageWithAllocationPrice]. + * Returns an immutable instance of [PackageWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -30432,18 +28598,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanPackageWithAllocationPrice = - NewPlanPackageWithAllocationPrice( + fun build(): PackageWithAllocation = + PackageWithAllocation( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), billableMetricId, @@ -30462,14 +28627,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanPackageWithAllocationPrice = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageWithAllocationConfig().validate() billableMetricId() @@ -30503,7 +28672,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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 (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -30673,131 +28844,6 @@ private constructor( 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 PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * 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 { - PACKAGE_WITH_ALLOCATION, - /** - * 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) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - 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 PackageWithAllocationConfig @JsonCreator private constructor( @@ -31742,7 +29788,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocation && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -31752,14 +29798,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanTierWithProrationPrice + class TieredWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -31783,9 +29829,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_proration_config") @ExcludeMissing @@ -31859,11 +29903,15 @@ private constructor( 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). + * 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). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -31988,16 +30036,6 @@ private constructor( */ @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]. * @@ -32131,14 +30169,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanTierWithProrationPrice]. + * Returns a mutable builder for constructing an instance of [TieredWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` @@ -32146,12 +30182,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanTierWithProrationPrice]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: 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() @@ -32169,29 +30205,24 @@ private constructor( 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 - currency = newPlanTierWithProrationPrice.currency - externalPriceId = newPlanTierWithProrationPrice.externalPriceId - fixedPriceQuantity = newPlanTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanTierWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanTierWithProrationPrice.invoicingCycleConfiguration - metadata = newPlanTierWithProrationPrice.metadata - additionalProperties = - newPlanTierWithProrationPrice.additionalProperties.toMutableMap() - } + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + currency = tieredWithProration.currency + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + additionalProperties = tieredWithProration.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -32217,18 +30248,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -32533,7 +30565,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanTierWithProrationPrice]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -32541,18 +30573,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanTierWithProrationPrice = - NewPlanTierWithProrationPrice( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, @@ -32571,14 +30602,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanTierWithProrationPrice = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithProrationConfig().validate() billableMetricId() @@ -32612,7 +30647,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -32782,131 +30817,6 @@ private constructor( 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( @@ -33851,7 +31761,7 @@ private constructor( return true } - return /* spotless:off */ other is NewPlanTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -33861,14 +31771,14 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanUnitWithProrationPrice + class UnitWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -33892,9 +31802,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_proration_config") @ExcludeMissing @@ -33968,11 +31876,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -34097,16 +32009,6 @@ private constructor( */ @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]. * @@ -34240,14 +32142,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanUnitWithProrationPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` @@ -34255,12 +32155,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanUnitWithProrationPrice]. */ + /** A builder for [UnitWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") private var name: JsonField? = null private var unitWithProrationConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -34278,29 +32178,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanUnitWithProrationPrice: NewPlanUnitWithProrationPrice) = - apply { - cadence = newPlanUnitWithProrationPrice.cadence - itemId = newPlanUnitWithProrationPrice.itemId - modelType = newPlanUnitWithProrationPrice.modelType - name = newPlanUnitWithProrationPrice.name - unitWithProrationConfig = - newPlanUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newPlanUnitWithProrationPrice.billableMetricId - billedInAdvance = newPlanUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newPlanUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newPlanUnitWithProrationPrice.conversionRate - currency = newPlanUnitWithProrationPrice.currency - externalPriceId = newPlanUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = newPlanUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newPlanUnitWithProrationPrice.metadata - additionalProperties = - newPlanUnitWithProrationPrice.additionalProperties.toMutableMap() - } + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + currency = unitWithProration.currency + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + metadata = unitWithProration.metadata + additionalProperties = unitWithProration.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -34326,18 +32221,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -34641,7 +32537,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanUnitWithProrationPrice]. + * Returns an immutable instance of [UnitWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -34649,18 +32545,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanUnitWithProrationPrice = - NewPlanUnitWithProrationPrice( + fun build(): UnitWithProration = + UnitWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithProrationConfig", unitWithProrationConfig), billableMetricId, @@ -34679,14 +32574,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanUnitWithProrationPrice = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithProrationConfig().validate() billableMetricId() @@ -34720,7 +32619,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_proration")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -34890,131 +32789,6 @@ private constructor( 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 UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_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 { - UNIT_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) { - UNIT_WITH_PRORATION -> Value.UNIT_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) { - UNIT_WITH_PRORATION -> Known.UNIT_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 UnitWithProrationConfig @JsonCreator private constructor( @@ -35958,7 +33732,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProration && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -35968,15 +33742,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "UnitWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanGroupedAllocationPrice + class GroupedAllocation private constructor( private val cadence: JsonField, private val groupedAllocationConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -36002,9 +33776,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -36083,11 +33855,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -36215,16 +33991,6 @@ private constructor( */ @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]. * @@ -36347,28 +34113,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanGroupedAllocationPrice]. + * Returns a mutable builder for constructing an instance of [GroupedAllocation]. * * The following fields are required: * ```java * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanGroupedAllocationPrice]. */ + /** A builder for [GroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedAllocationConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -36385,29 +34149,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanGroupedAllocationPrice: NewPlanGroupedAllocationPrice) = - apply { - cadence = newPlanGroupedAllocationPrice.cadence - groupedAllocationConfig = - newPlanGroupedAllocationPrice.groupedAllocationConfig - itemId = newPlanGroupedAllocationPrice.itemId - modelType = newPlanGroupedAllocationPrice.modelType - name = newPlanGroupedAllocationPrice.name - billableMetricId = newPlanGroupedAllocationPrice.billableMetricId - billedInAdvance = newPlanGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newPlanGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newPlanGroupedAllocationPrice.conversionRate - currency = newPlanGroupedAllocationPrice.currency - externalPriceId = newPlanGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = newPlanGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newPlanGroupedAllocationPrice.metadata - additionalProperties = - newPlanGroupedAllocationPrice.additionalProperties.toMutableMap() - } + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + currency = groupedAllocation.currency + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + metadata = groupedAllocation.metadata + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -36447,18 +34206,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -36748,7 +34508,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanGroupedAllocationPrice]. + * Returns an immutable instance of [GroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -36757,18 +34517,17 @@ private constructor( * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanGroupedAllocationPrice = - NewPlanGroupedAllocationPrice( + fun build(): GroupedAllocation = + GroupedAllocation( checkRequired("cadence", cadence), checkRequired("groupedAllocationConfig", groupedAllocationConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -36786,7 +34545,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanGroupedAllocationPrice = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -36794,7 +34553,11 @@ private constructor( cadence().validate() groupedAllocationConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -36828,7 +34591,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -37109,131 +34872,6 @@ private constructor( "GroupedAllocationConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * 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 { - GROUPED_ALLOCATION, - /** - * 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) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -38065,7 +35703,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocation && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -38075,16 +35713,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanGroupedWithProratedMinimumPrice + class GroupedWithProratedMinimum private constructor( private val cadence: JsonField, private val groupedWithProratedMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -38111,9 +35749,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -38192,11 +35828,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -38324,16 +35964,6 @@ private constructor( */ @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]. * @@ -38457,21 +36087,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPlanGroupedWithProratedMinimumPrice]. + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanGroupedWithProratedMinimumPrice]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -38479,7 +36108,7 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_with_prorated_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -38496,29 +36125,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanGroupedWithProratedMinimumPrice: NewPlanGroupedWithProratedMinimumPrice - ) = apply { - cadence = newPlanGroupedWithProratedMinimumPrice.cadence + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { + cadence = groupedWithProratedMinimum.cadence groupedWithProratedMinimumConfig = - newPlanGroupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig - itemId = newPlanGroupedWithProratedMinimumPrice.itemId - modelType = newPlanGroupedWithProratedMinimumPrice.modelType - name = newPlanGroupedWithProratedMinimumPrice.name - billableMetricId = newPlanGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = newPlanGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newPlanGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = newPlanGroupedWithProratedMinimumPrice.conversionRate - currency = newPlanGroupedWithProratedMinimumPrice.currency - externalPriceId = newPlanGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = newPlanGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanGroupedWithProratedMinimumPrice.invoiceGroupingKey + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + currency = groupedWithProratedMinimum.currency + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey invoicingCycleConfiguration = - newPlanGroupedWithProratedMinimumPrice.invoicingCycleConfiguration - metadata = newPlanGroupedWithProratedMinimumPrice.metadata + groupedWithProratedMinimum.invoicingCycleConfiguration + metadata = groupedWithProratedMinimum.metadata additionalProperties = - newPlanGroupedWithProratedMinimumPrice.additionalProperties.toMutableMap() + groupedWithProratedMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -38562,18 +36188,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -38863,7 +36490,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanGroupedWithProratedMinimumPrice]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -38872,21 +36499,20 @@ private constructor( * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanGroupedWithProratedMinimumPrice = - NewPlanGroupedWithProratedMinimumPrice( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithProratedMinimumConfig", groupedWithProratedMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -38904,7 +36530,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanGroupedWithProratedMinimumPrice = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -38912,7 +36538,11 @@ private constructor( cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -38946,7 +36576,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -39229,132 +36861,6 @@ private constructor( "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -40186,7 +37692,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimum && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -40196,15 +37702,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanGroupedWithMeteredMinimumPrice + class GroupedWithMeteredMinimum private constructor( private val cadence: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -40231,9 +37737,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -40312,11 +37816,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -40444,16 +37952,6 @@ private constructor( */ @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]. * @@ -40577,21 +38075,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPlanGroupedWithMeteredMinimumPrice]. + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanGroupedWithMeteredMinimumPrice]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -40599,7 +38096,7 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_with_metered_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -40616,29 +38113,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanGroupedWithMeteredMinimumPrice: NewPlanGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newPlanGroupedWithMeteredMinimumPrice.cadence + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { + cadence = groupedWithMeteredMinimum.cadence groupedWithMeteredMinimumConfig = - newPlanGroupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig - itemId = newPlanGroupedWithMeteredMinimumPrice.itemId - modelType = newPlanGroupedWithMeteredMinimumPrice.modelType - name = newPlanGroupedWithMeteredMinimumPrice.name - billableMetricId = newPlanGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = newPlanGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newPlanGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = newPlanGroupedWithMeteredMinimumPrice.conversionRate - currency = newPlanGroupedWithMeteredMinimumPrice.currency - externalPriceId = newPlanGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = newPlanGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanGroupedWithMeteredMinimumPrice.invoiceGroupingKey + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + currency = groupedWithMeteredMinimum.currency + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey invoicingCycleConfiguration = - newPlanGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration - metadata = newPlanGroupedWithMeteredMinimumPrice.metadata + groupedWithMeteredMinimum.invoicingCycleConfiguration + metadata = groupedWithMeteredMinimum.metadata additionalProperties = - newPlanGroupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() + groupedWithMeteredMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -40680,18 +38174,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -40981,7 +38476,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanGroupedWithMeteredMinimumPrice]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -40990,21 +38485,20 @@ private constructor( * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanGroupedWithMeteredMinimumPrice = - NewPlanGroupedWithMeteredMinimumPrice( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithMeteredMinimumConfig", groupedWithMeteredMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -41022,7 +38516,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanGroupedWithMeteredMinimumPrice = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -41030,7 +38524,11 @@ private constructor( cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -41064,7 +38562,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -41347,131 +38847,6 @@ private constructor( "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -42303,7 +39678,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimum && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -42313,15 +39688,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanMatrixWithDisplayNamePrice + class MatrixWithDisplayName private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixWithDisplayNameConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -42348,9 +39723,7 @@ private constructor( @ExcludeMissing matrixWithDisplayNameConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -42429,11 +39802,15 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -42561,16 +39938,6 @@ private constructor( fun _matrixWithDisplayNameConfig(): JsonField = matrixWithDisplayNameConfig - /** - * 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]. * @@ -42694,28 +40061,27 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPlanMatrixWithDisplayNamePrice]. + * [MatrixWithDisplayName]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanMatrixWithDisplayNamePrice]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null private var matrixWithDisplayNameConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -42732,29 +40098,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanMatrixWithDisplayNamePrice: NewPlanMatrixWithDisplayNamePrice - ) = apply { - cadence = newPlanMatrixWithDisplayNamePrice.cadence - itemId = newPlanMatrixWithDisplayNamePrice.itemId - matrixWithDisplayNameConfig = - newPlanMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newPlanMatrixWithDisplayNamePrice.modelType - name = newPlanMatrixWithDisplayNamePrice.name - billableMetricId = newPlanMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newPlanMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newPlanMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newPlanMatrixWithDisplayNamePrice.conversionRate - currency = newPlanMatrixWithDisplayNamePrice.currency - externalPriceId = newPlanMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = newPlanMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanMatrixWithDisplayNamePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newPlanMatrixWithDisplayNamePrice.metadata - additionalProperties = - newPlanMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId + matrixWithDisplayNameConfig = matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + currency = matrixWithDisplayName.currency + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = matrixWithDisplayName.invoicingCycleConfiguration + metadata = matrixWithDisplayName.metadata + additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -42796,18 +40156,19 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -43097,7 +40458,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanMatrixWithDisplayNamePrice]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -43106,18 +40467,17 @@ private constructor( * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanMatrixWithDisplayNamePrice = - NewPlanMatrixWithDisplayNamePrice( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -43135,7 +40495,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanMatrixWithDisplayNamePrice = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -43143,7 +40503,11 @@ private constructor( cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -43177,7 +40541,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -43459,131 +40825,6 @@ private constructor( "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * 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 { - MATRIX_WITH_DISPLAY_NAME, - /** - * 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) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -44415,7 +41656,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayName && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -44425,15 +41666,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanBulkWithProrationPrice + class BulkWithProration private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -44459,9 +41700,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -44540,11 +41779,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -44672,16 +41915,6 @@ private constructor( */ @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]. * @@ -44804,28 +42037,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanBulkWithProrationPrice]. + * Returns a mutable builder for constructing an instance of [BulkWithProration]. * * The following fields are required: * ```java * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanBulkWithProrationPrice]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -44842,29 +42073,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPlanBulkWithProrationPrice: NewPlanBulkWithProrationPrice) = - apply { - bulkWithProrationConfig = - newPlanBulkWithProrationPrice.bulkWithProrationConfig - cadence = newPlanBulkWithProrationPrice.cadence - itemId = newPlanBulkWithProrationPrice.itemId - modelType = newPlanBulkWithProrationPrice.modelType - name = newPlanBulkWithProrationPrice.name - billableMetricId = newPlanBulkWithProrationPrice.billableMetricId - billedInAdvance = newPlanBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newPlanBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newPlanBulkWithProrationPrice.conversionRate - currency = newPlanBulkWithProrationPrice.currency - externalPriceId = newPlanBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = newPlanBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newPlanBulkWithProrationPrice.metadata - additionalProperties = - newPlanBulkWithProrationPrice.additionalProperties.toMutableMap() - } + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + currency = bulkWithProration.currency + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + metadata = bulkWithProration.metadata + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() + } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) @@ -44904,18 +42130,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -45205,7 +42432,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanBulkWithProrationPrice]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -45214,18 +42441,17 @@ private constructor( * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanBulkWithProrationPrice = - NewPlanBulkWithProrationPrice( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -45243,7 +42469,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanBulkWithProrationPrice = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -45251,7 +42477,11 @@ private constructor( bulkWithProrationConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -45285,7 +42515,7 @@ private constructor( (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -45566,131 +42796,6 @@ private constructor( 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 BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_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 { - BULK_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) { - BULK_WITH_PRORATION -> Value.BULK_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) { - BULK_WITH_PRORATION -> Known.BULK_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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -46522,7 +43627,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkWithProration && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -46532,15 +43637,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanGroupedTieredPackagePrice + class GroupedTieredPackage private constructor( private val cadence: JsonField, private val groupedTieredPackageConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -46567,9 +43672,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -46648,11 +43751,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -46780,16 +43887,6 @@ private constructor( */ @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]. * @@ -46912,29 +44009,27 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewPlanGroupedTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. * * The following fields are required: * ```java * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanGroupedTieredPackagePrice]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedTieredPackageConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -46951,29 +44046,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanGroupedTieredPackagePrice: NewPlanGroupedTieredPackagePrice - ) = apply { - cadence = newPlanGroupedTieredPackagePrice.cadence - groupedTieredPackageConfig = - newPlanGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newPlanGroupedTieredPackagePrice.itemId - modelType = newPlanGroupedTieredPackagePrice.modelType - name = newPlanGroupedTieredPackagePrice.name - billableMetricId = newPlanGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newPlanGroupedTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newPlanGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newPlanGroupedTieredPackagePrice.conversionRate - currency = newPlanGroupedTieredPackagePrice.currency - externalPriceId = newPlanGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = newPlanGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanGroupedTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newPlanGroupedTieredPackagePrice.metadata - additionalProperties = - newPlanGroupedTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + currency = groupedTieredPackage.currency + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = groupedTieredPackage.invoicingCycleConfiguration + metadata = groupedTieredPackage.metadata + additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -47015,18 +44104,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -47316,7 +44406,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanGroupedTieredPackagePrice]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -47325,18 +44415,17 @@ private constructor( * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanGroupedTieredPackagePrice = - NewPlanGroupedTieredPackagePrice( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("cadence", cadence), checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -47354,7 +44443,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanGroupedTieredPackagePrice = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -47362,7 +44451,11 @@ private constructor( cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -47396,7 +44489,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -47678,131 +44771,6 @@ private constructor( "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * 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 { - GROUPED_TIERED_PACKAGE, - /** - * 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) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -48634,7 +45602,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPackage && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -48644,15 +45612,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanMaxGroupTieredPackagePrice + class MaxGroupTieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, private val maxGroupTieredPackageConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -48679,9 +45647,7 @@ private constructor( @ExcludeMissing maxGroupTieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -48760,11 +45726,15 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_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). + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -48892,16 +45862,6 @@ private constructor( fun _maxGroupTieredPackageConfig(): JsonField = maxGroupTieredPackageConfig - /** - * 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]. * @@ -49025,28 +45985,27 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPlanMaxGroupTieredPackagePrice]. + * [MaxGroupTieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanMaxGroupTieredPackagePrice]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null private var maxGroupTieredPackageConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -49063,29 +46022,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanMaxGroupTieredPackagePrice: NewPlanMaxGroupTieredPackagePrice - ) = apply { - cadence = newPlanMaxGroupTieredPackagePrice.cadence - itemId = newPlanMaxGroupTieredPackagePrice.itemId - maxGroupTieredPackageConfig = - newPlanMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newPlanMaxGroupTieredPackagePrice.modelType - name = newPlanMaxGroupTieredPackagePrice.name - billableMetricId = newPlanMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newPlanMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newPlanMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newPlanMaxGroupTieredPackagePrice.conversionRate - currency = newPlanMaxGroupTieredPackagePrice.currency - externalPriceId = newPlanMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = newPlanMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newPlanMaxGroupTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newPlanMaxGroupTieredPackagePrice.metadata - additionalProperties = - newPlanMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId + maxGroupTieredPackageConfig = maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + currency = maxGroupTieredPackage.currency + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = maxGroupTieredPackage.invoicingCycleConfiguration + metadata = maxGroupTieredPackage.metadata + additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -49127,18 +46080,19 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -49428,7 +46382,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanMaxGroupTieredPackagePrice]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -49437,18 +46391,17 @@ private constructor( * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanMaxGroupTieredPackagePrice = - NewPlanMaxGroupTieredPackagePrice( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -49466,7 +46419,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanMaxGroupTieredPackagePrice = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -49474,7 +46427,11 @@ private constructor( cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -49508,7 +46465,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -49790,131 +46749,6 @@ private constructor( "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * 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 { - MAX_GROUP_TIERED_PACKAGE, - /** - * 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) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -50746,7 +47580,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MaxGroupTieredPackage && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -50756,14 +47590,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanScalableMatrixWithUnitPricingPrice + class ScalableMatrixWithUnitPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithUnitPricingConfig: JsonField, @@ -50788,9 +47622,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("scalable_matrix_with_unit_pricing_config") @ExcludeMissing @@ -50866,11 +47698,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -50997,16 +47833,6 @@ private constructor( */ @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]. * @@ -51141,13 +47967,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPlanScalableMatrixWithUnitPricingPrice]. + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` @@ -51155,12 +47980,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var scalableMatrixWithUnitPricingConfig: JsonField? = @@ -51180,35 +48006,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanScalableMatrixWithUnitPricingPrice: - NewPlanScalableMatrixWithUnitPricingPrice - ) = apply { - cadence = newPlanScalableMatrixWithUnitPricingPrice.cadence - itemId = newPlanScalableMatrixWithUnitPricingPrice.itemId - modelType = newPlanScalableMatrixWithUnitPricingPrice.modelType - name = newPlanScalableMatrixWithUnitPricingPrice.name - scalableMatrixWithUnitPricingConfig = - newPlanScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = newPlanScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = newPlanScalableMatrixWithUnitPricingPrice.billedInAdvance - billingCycleConfiguration = - newPlanScalableMatrixWithUnitPricingPrice.billingCycleConfiguration - conversionRate = newPlanScalableMatrixWithUnitPricingPrice.conversionRate - currency = newPlanScalableMatrixWithUnitPricingPrice.currency - externalPriceId = newPlanScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newPlanScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newPlanScalableMatrixWithUnitPricingPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration - metadata = newPlanScalableMatrixWithUnitPricingPrice.metadata - additionalProperties = - newPlanScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() - } + internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = + apply { + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + currency = scalableMatrixWithUnitPricing.currency + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithUnitPricing.metadata + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -51234,18 +48054,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -51556,7 +48377,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanScalableMatrixWithUnitPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -51564,18 +48385,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanScalableMatrixWithUnitPricingPrice = - NewPlanScalableMatrixWithUnitPricingPrice( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithUnitPricingConfig", @@ -51597,14 +48417,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanScalableMatrixWithUnitPricingPrice = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -51638,7 +48462,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -51808,132 +48634,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - 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 ScalableMatrixWithUnitPricingConfig @JsonCreator private constructor( @@ -52879,7 +49579,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithUnitPricing && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -52889,14 +49589,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanScalableMatrixWithTieredPricingPrice + class ScalableMatrixWithTieredPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithTieredPricingConfig: JsonField, @@ -52921,9 +49621,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("scalable_matrix_with_tiered_pricing_config") @ExcludeMissing @@ -52999,11 +49697,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -53130,16 +49832,6 @@ private constructor( */ @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]. * @@ -53275,13 +49967,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPlanScalableMatrixWithTieredPricingPrice]. + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` @@ -53289,12 +49980,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanScalableMatrixWithTieredPricingPrice]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var scalableMatrixWithTieredPricingConfig: JsonField? = @@ -53315,33 +50007,28 @@ private constructor( @JvmSynthetic internal fun from( - newPlanScalableMatrixWithTieredPricingPrice: - NewPlanScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = apply { - cadence = newPlanScalableMatrixWithTieredPricingPrice.cadence - itemId = newPlanScalableMatrixWithTieredPricingPrice.itemId - modelType = newPlanScalableMatrixWithTieredPricingPrice.modelType - name = newPlanScalableMatrixWithTieredPricingPrice.name + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name scalableMatrixWithTieredPricingConfig = - newPlanScalableMatrixWithTieredPricingPrice - .scalableMatrixWithTieredPricingConfig - billableMetricId = newPlanScalableMatrixWithTieredPricingPrice.billableMetricId - billedInAdvance = newPlanScalableMatrixWithTieredPricingPrice.billedInAdvance + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance billingCycleConfiguration = - newPlanScalableMatrixWithTieredPricingPrice.billingCycleConfiguration - conversionRate = newPlanScalableMatrixWithTieredPricingPrice.conversionRate - currency = newPlanScalableMatrixWithTieredPricingPrice.currency - externalPriceId = newPlanScalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = - newPlanScalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newPlanScalableMatrixWithTieredPricingPrice.invoiceGroupingKey + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + currency = scalableMatrixWithTieredPricing.currency + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey invoicingCycleConfiguration = - newPlanScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration - metadata = newPlanScalableMatrixWithTieredPricingPrice.metadata + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithTieredPricing.metadata additionalProperties = - newPlanScalableMatrixWithTieredPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -53368,18 +50055,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -53691,7 +50379,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanScalableMatrixWithTieredPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -53699,18 +50387,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanScalableMatrixWithTieredPricingPrice = - NewPlanScalableMatrixWithTieredPricingPrice( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithTieredPricingConfig", @@ -53732,14 +50419,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanScalableMatrixWithTieredPricingPrice = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -53773,7 +50464,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -53943,135 +50636,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - 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 ScalableMatrixWithTieredPricingConfig @JsonCreator private constructor( @@ -55018,7 +51582,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithTieredPricing && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -55028,15 +51592,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewPlanCumulativeGroupedBulkPrice + class CumulativeGroupedBulk private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -55063,9 +51627,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -55144,11 +51706,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -55276,16 +51842,6 @@ private constructor( */ @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]. * @@ -55409,28 +51965,27 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPlanCumulativeGroupedBulkPrice]. + * [CumulativeGroupedBulk]. * * The following fields are required: * ```java * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewPlanCumulativeGroupedBulkPrice]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var cumulativeGroupedBulkConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -55447,29 +52002,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newPlanCumulativeGroupedBulkPrice: NewPlanCumulativeGroupedBulkPrice - ) = apply { - cadence = newPlanCumulativeGroupedBulkPrice.cadence - cumulativeGroupedBulkConfig = - newPlanCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - itemId = newPlanCumulativeGroupedBulkPrice.itemId - modelType = newPlanCumulativeGroupedBulkPrice.modelType - name = newPlanCumulativeGroupedBulkPrice.name - billableMetricId = newPlanCumulativeGroupedBulkPrice.billableMetricId - billedInAdvance = newPlanCumulativeGroupedBulkPrice.billedInAdvance - billingCycleConfiguration = - newPlanCumulativeGroupedBulkPrice.billingCycleConfiguration - conversionRate = newPlanCumulativeGroupedBulkPrice.conversionRate - currency = newPlanCumulativeGroupedBulkPrice.currency - externalPriceId = newPlanCumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = newPlanCumulativeGroupedBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newPlanCumulativeGroupedBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newPlanCumulativeGroupedBulkPrice.invoicingCycleConfiguration - metadata = newPlanCumulativeGroupedBulkPrice.metadata - additionalProperties = - newPlanCumulativeGroupedBulkPrice.additionalProperties.toMutableMap() + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + currency = cumulativeGroupedBulk.currency + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration + metadata = cumulativeGroupedBulk.metadata + additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -55511,18 +52060,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -55812,7 +52362,7 @@ private constructor( } /** - * Returns an immutable instance of [NewPlanCumulativeGroupedBulkPrice]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -55821,18 +52371,17 @@ private constructor( * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPlanCumulativeGroupedBulkPrice = - NewPlanCumulativeGroupedBulkPrice( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("cadence", cadence), checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -55850,7 +52399,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPlanCumulativeGroupedBulkPrice = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -55858,7 +52407,11 @@ private constructor( cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -55892,7 +52445,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -56174,131 +52729,6 @@ private constructor( "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * 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 { - CUMULATIVE_GROUPED_BULK, - /** - * 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) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -57130,7 +53560,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CumulativeGroupedBulk && 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -57140,7 +53570,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPlanCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, 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/PlanExternalPlanIdFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt index 1ef99371..1c3d068d 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to fetch [plan](/core-concepts##plan-and-price) details given an @@ -26,12 +27,12 @@ import java.util.Objects */ class PlanExternalPlanIdFetchParams private constructor( - private val externalPlanId: String, + private val externalPlanId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun externalPlanId(): String = externalPlanId + fun externalPlanId(): Optional = Optional.ofNullable(externalPlanId) fun _additionalHeaders(): Headers = additionalHeaders @@ -41,14 +42,11 @@ private constructor( companion object { + @JvmStatic fun none(): PlanExternalPlanIdFetchParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [PlanExternalPlanIdFetchParams]. - * - * The following fields are required: - * ```java - * .externalPlanId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -67,7 +65,11 @@ private constructor( additionalQueryParams = planExternalPlanIdFetchParams.additionalQueryParams.toBuilder() } - fun externalPlanId(externalPlanId: String) = apply { this.externalPlanId = externalPlanId } + fun externalPlanId(externalPlanId: String?) = apply { this.externalPlanId = externalPlanId } + + /** Alias for calling [Builder.externalPlanId] with `externalPlanId.orElse(null)`. */ + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -171,17 +173,10 @@ private constructor( * Returns an immutable instance of [PlanExternalPlanIdFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalPlanId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams( - checkRequired("externalPlanId", externalPlanId), + externalPlanId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -189,7 +184,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalPlanId + 0 -> externalPlanId ?: "" else -> "" } 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 eadfb19f..a82ba300 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 @@ -11,7 +11,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -28,13 +27,13 @@ import kotlin.jvm.optionals.getOrNull */ class PlanExternalPlanIdUpdateParams private constructor( - private val otherExternalPlanId: String, + private val otherExternalPlanId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun otherExternalPlanId(): String = otherExternalPlanId + fun otherExternalPlanId(): Optional = Optional.ofNullable(otherExternalPlanId) /** * An optional user-defined ID for this plan resource, used throughout the system as an alias @@ -79,14 +78,11 @@ private constructor( companion object { + @JvmStatic fun none(): PlanExternalPlanIdUpdateParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [PlanExternalPlanIdUpdateParams]. - * - * The following fields are required: - * ```java - * .otherExternalPlanId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -107,10 +103,16 @@ private constructor( additionalQueryParams = planExternalPlanIdUpdateParams.additionalQueryParams.toBuilder() } - fun otherExternalPlanId(otherExternalPlanId: String) = apply { + fun otherExternalPlanId(otherExternalPlanId: String?) = apply { this.otherExternalPlanId = otherExternalPlanId } + /** + * Alias for calling [Builder.otherExternalPlanId] with `otherExternalPlanId.orElse(null)`. + */ + fun otherExternalPlanId(otherExternalPlanId: Optional) = + otherExternalPlanId(otherExternalPlanId.getOrNull()) + /** * Sets the entire request body. * @@ -283,17 +285,10 @@ private constructor( * Returns an immutable instance of [PlanExternalPlanIdUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .otherExternalPlanId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams( - checkRequired("otherExternalPlanId", otherExternalPlanId), + otherExternalPlanId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -304,7 +299,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> otherExternalPlanId + 0 -> otherExternalPlanId ?: "" else -> "" } 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 94bd31a9..a6427bb0 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to fetch [plan](/core-concepts#plan-and-price) details given a plan @@ -27,12 +28,12 @@ import java.util.Objects */ class PlanFetchParams private constructor( - private val planId: String, + private val planId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun planId(): String = planId + fun planId(): Optional = Optional.ofNullable(planId) fun _additionalHeaders(): Headers = additionalHeaders @@ -42,14 +43,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [PlanFetchParams]. - * - * The following fields are required: - * ```java - * .planId() - * ``` - */ + @JvmStatic fun none(): PlanFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PlanFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -67,7 +63,10 @@ private constructor( additionalQueryParams = planFetchParams.additionalQueryParams.toBuilder() } - fun planId(planId: String) = apply { this.planId = planId } + 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 additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -171,25 +170,14 @@ private constructor( * Returns an immutable instance of [PlanFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .planId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): PlanFetchParams = - PlanFetchParams( - checkRequired("planId", planId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + PlanFetchParams(planId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> planId + 0 -> planId ?: "" else -> "" } 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 3442a463..c2506318 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.PlanService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [PlanService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: PlanService, private val params: PlanListParams, private val response: PlanListPageResponse, -) { +) : Page { /** * Delegates to [PlanListPageResponse], but gracefully handles missing data. @@ -33,30 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): PlanListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): PlanListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): PlanListParams = params @@ -125,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: PlanListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 f12c610f..7cb079f9 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.PlanServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [PlanServiceAsync.list] */ class PlanListPageAsync private constructor( private val service: PlanServiceAsync, + private val streamHandlerExecutor: Executor, private val params: PlanListParams, private val response: PlanListPageResponse, -) { +) : PageAsync { /** * Delegates to [PlanListPageResponse], but gracefully handles missing data. @@ -34,33 +36,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): PlanListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): PlanListParams = params @@ -78,6 +69,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -89,18 +81,24 @@ private constructor( class Builder internal constructor() { private var service: PlanServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: PlanListParams? = null private var response: PlanListPageResponse? = null @JvmSynthetic internal fun from(planListPageAsync: PlanListPageAsync) = apply { service = planListPageAsync.service + streamHandlerExecutor = planListPageAsync.streamHandlerExecutor params = planListPageAsync.params response = planListPageAsync.response } fun service(service: PlanServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: PlanListParams) = apply { this.params = params } @@ -115,6 +113,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -124,47 +123,22 @@ private constructor( fun build(): PlanListPageAsync = PlanListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: PlanListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Plan) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is PlanListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "PlanListPageAsync{service=$service, params=$params, response=$response}" + "PlanListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 f47ff136..25b9bd6d 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 @@ -11,7 +11,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -28,13 +27,13 @@ import kotlin.jvm.optionals.getOrNull */ class PlanUpdateParams private constructor( - private val planId: String, + private val planId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun planId(): String = planId + fun planId(): Optional = Optional.ofNullable(planId) /** * An optional user-defined ID for this plan resource, used throughout the system as an alias @@ -79,14 +78,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [PlanUpdateParams]. - * - * The following fields are required: - * ```java - * .planId() - * ``` - */ + @JvmStatic fun none(): PlanUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PlanUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -106,7 +100,10 @@ private constructor( additionalQueryParams = planUpdateParams.additionalQueryParams.toBuilder() } - fun planId(planId: String) = apply { this.planId = planId } + fun planId(planId: String?) = apply { this.planId = planId } + + /** Alias for calling [Builder.planId] with `planId.orElse(null)`. */ + fun planId(planId: Optional) = planId(planId.getOrNull()) /** * Sets the entire request body. @@ -280,17 +277,10 @@ private constructor( * Returns an immutable instance of [PlanUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .planId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): PlanUpdateParams = PlanUpdateParams( - checkRequired("planId", planId), + planId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -301,7 +291,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> planId + 0 -> planId ?: "" else -> "" } 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 6aa20c66..d2dc125f 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 @@ -29,6 +29,7 @@ import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.Unit as KUnit import kotlin.jvm.optionals.getOrNull /** @@ -47,113 +48,109 @@ import kotlin.jvm.optionals.getOrNull @JsonSerialize(using = Price.Serializer::class) class Price private constructor( - private val unit: UnitPrice? = null, - private val packagePrice: PackagePrice? = null, - private val matrix: MatrixPrice? = null, - private val tiered: TieredPrice? = null, - private val tieredBps: TieredBpsPrice? = null, - private val bps: BpsPrice? = null, - private val bulkBps: BulkBpsPrice? = null, - private val bulk: BulkPrice? = null, - private val thresholdTotalAmount: ThresholdTotalAmountPrice? = null, - private val tieredPackage: TieredPackagePrice? = null, - private val groupedTiered: GroupedTieredPrice? = null, - private val tieredWithMinimum: TieredWithMinimumPrice? = null, - private val tieredPackageWithMinimum: TieredPackageWithMinimumPrice? = null, - private val packageWithAllocation: PackageWithAllocationPrice? = null, - private val unitWithPercent: UnitWithPercentPrice? = null, - private val matrixWithAllocation: MatrixWithAllocationPrice? = null, - private val tieredWithProration: TieredWithProrationPrice? = null, - private val unitWithProration: UnitWithProrationPrice? = null, - private val groupedAllocation: GroupedAllocationPrice? = null, - private val groupedWithProratedMinimum: GroupedWithProratedMinimumPrice? = null, - private val groupedWithMeteredMinimum: GroupedWithMeteredMinimumPrice? = null, - private val matrixWithDisplayName: MatrixWithDisplayNamePrice? = null, - private val bulkWithProration: BulkWithProrationPrice? = null, - private val groupedTieredPackage: GroupedTieredPackagePrice? = null, - private val maxGroupTieredPackage: MaxGroupTieredPackagePrice? = null, - private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricingPrice? = null, - private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricingPrice? = null, - private val cumulativeGroupedBulk: CumulativeGroupedBulkPrice? = null, + 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 thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val groupedTiered: GroupedTiered? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = 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 _json: JsonValue? = null, ) { - fun unit(): Optional = Optional.ofNullable(unit) + fun unit(): Optional = Optional.ofNullable(unit) - fun packagePrice(): Optional = Optional.ofNullable(packagePrice) + fun package_(): Optional = Optional.ofNullable(package_) - fun matrix(): Optional = Optional.ofNullable(matrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun tiered(): Optional = Optional.ofNullable(tiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun tieredBps(): Optional = Optional.ofNullable(tieredBps) + fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - fun bps(): Optional = Optional.ofNullable(bps) + fun bps(): Optional = Optional.ofNullable(bps) - fun bulkBps(): Optional = Optional.ofNullable(bulkBps) + fun bulkBps(): Optional = Optional.ofNullable(bulkBps) - fun bulk(): Optional = Optional.ofNullable(bulk) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun thresholdTotalAmount(): Optional = + fun thresholdTotalAmount(): Optional = Optional.ofNullable(thresholdTotalAmount) - fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) + fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) - fun tieredWithMinimum(): Optional = - Optional.ofNullable(tieredWithMinimum) + fun tieredWithMinimum(): Optional = Optional.ofNullable(tieredWithMinimum) - fun tieredPackageWithMinimum(): Optional = + fun tieredPackageWithMinimum(): Optional = Optional.ofNullable(tieredPackageWithMinimum) - fun packageWithAllocation(): Optional = + fun packageWithAllocation(): Optional = Optional.ofNullable(packageWithAllocation) - fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun matrixWithAllocation(): Optional = + fun matrixWithAllocation(): Optional = Optional.ofNullable(matrixWithAllocation) - fun tieredWithProration(): Optional = + fun tieredWithProration(): Optional = Optional.ofNullable(tieredWithProration) - fun unitWithProration(): Optional = - Optional.ofNullable(unitWithProration) + fun unitWithProration(): Optional = Optional.ofNullable(unitWithProration) - fun groupedAllocation(): Optional = - Optional.ofNullable(groupedAllocation) + fun groupedAllocation(): Optional = Optional.ofNullable(groupedAllocation) - fun groupedWithProratedMinimum(): Optional = + fun groupedWithProratedMinimum(): Optional = Optional.ofNullable(groupedWithProratedMinimum) - fun groupedWithMeteredMinimum(): Optional = + fun groupedWithMeteredMinimum(): Optional = Optional.ofNullable(groupedWithMeteredMinimum) - fun matrixWithDisplayName(): Optional = + fun matrixWithDisplayName(): Optional = Optional.ofNullable(matrixWithDisplayName) - fun bulkWithProration(): Optional = - Optional.ofNullable(bulkWithProration) + fun bulkWithProration(): Optional = Optional.ofNullable(bulkWithProration) - fun groupedTieredPackage(): Optional = + fun groupedTieredPackage(): Optional = Optional.ofNullable(groupedTieredPackage) - fun maxGroupTieredPackage(): Optional = + fun maxGroupTieredPackage(): Optional = Optional.ofNullable(maxGroupTieredPackage) - fun scalableMatrixWithUnitPricing(): Optional = + fun scalableMatrixWithUnitPricing(): Optional = Optional.ofNullable(scalableMatrixWithUnitPricing) - fun scalableMatrixWithTieredPricing(): Optional = + fun scalableMatrixWithTieredPricing(): Optional = Optional.ofNullable(scalableMatrixWithTieredPricing) - fun cumulativeGroupedBulk(): Optional = + fun cumulativeGroupedBulk(): Optional = Optional.ofNullable(cumulativeGroupedBulk) fun isUnit(): Boolean = unit != null - fun isPackagePrice(): Boolean = packagePrice != null + fun isPackage(): Boolean = package_ != null fun isMatrix(): Boolean = matrix != null @@ -207,77 +204,73 @@ private constructor( fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun asUnit(): UnitPrice = unit.getOrThrow("unit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asPackagePrice(): PackagePrice = packagePrice.getOrThrow("packagePrice") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asMatrix(): MatrixPrice = matrix.getOrThrow("matrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asTiered(): TieredPrice = tiered.getOrThrow("tiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asTieredBps(): TieredBpsPrice = tieredBps.getOrThrow("tieredBps") + fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - fun asBps(): BpsPrice = bps.getOrThrow("bps") + fun asBps(): Bps = bps.getOrThrow("bps") - fun asBulkBps(): BulkBpsPrice = bulkBps.getOrThrow("bulkBps") + fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") - fun asBulk(): BulkPrice = bulk.getOrThrow("bulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") - fun asThresholdTotalAmount(): ThresholdTotalAmountPrice = + fun asThresholdTotalAmount(): ThresholdTotalAmount = thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asTieredPackage(): TieredPackagePrice = tieredPackage.getOrThrow("tieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asGroupedTiered(): GroupedTieredPrice = groupedTiered.getOrThrow("groupedTiered") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asTieredWithMinimum(): TieredWithMinimumPrice = - tieredWithMinimum.getOrThrow("tieredWithMinimum") + fun asTieredWithMinimum(): TieredWithMinimum = tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asTieredPackageWithMinimum(): TieredPackageWithMinimumPrice = + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun asPackageWithAllocation(): PackageWithAllocationPrice = + fun asPackageWithAllocation(): PackageWithAllocation = packageWithAllocation.getOrThrow("packageWithAllocation") - fun asUnitWithPercent(): UnitWithPercentPrice = unitWithPercent.getOrThrow("unitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asMatrixWithAllocation(): MatrixWithAllocationPrice = + fun asMatrixWithAllocation(): MatrixWithAllocation = matrixWithAllocation.getOrThrow("matrixWithAllocation") - fun asTieredWithProration(): TieredWithProrationPrice = + fun asTieredWithProration(): TieredWithProration = tieredWithProration.getOrThrow("tieredWithProration") - fun asUnitWithProration(): UnitWithProrationPrice = - unitWithProration.getOrThrow("unitWithProration") + fun asUnitWithProration(): UnitWithProration = unitWithProration.getOrThrow("unitWithProration") - fun asGroupedAllocation(): GroupedAllocationPrice = - groupedAllocation.getOrThrow("groupedAllocation") + fun asGroupedAllocation(): GroupedAllocation = groupedAllocation.getOrThrow("groupedAllocation") - fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimumPrice = + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimumPrice = + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - fun asMatrixWithDisplayName(): MatrixWithDisplayNamePrice = + fun asMatrixWithDisplayName(): MatrixWithDisplayName = matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asBulkWithProration(): BulkWithProrationPrice = - bulkWithProration.getOrThrow("bulkWithProration") + fun asBulkWithProration(): BulkWithProration = bulkWithProration.getOrThrow("bulkWithProration") - fun asGroupedTieredPackage(): GroupedTieredPackagePrice = + fun asGroupedTieredPackage(): GroupedTieredPackage = groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asMaxGroupTieredPackage(): MaxGroupTieredPackagePrice = + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricingPrice = + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricingPrice = + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asCumulativeGroupedBulk(): CumulativeGroupedBulkPrice = + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun _json(): Optional = Optional.ofNullable(_json) @@ -285,7 +278,7 @@ private constructor( fun accept(visitor: Visitor): T = when { unit != null -> visitor.visitUnit(unit) - packagePrice != null -> visitor.visitPackagePrice(packagePrice) + package_ != null -> visitor.visitPackage(package_) matrix != null -> visitor.visitMatrix(matrix) tiered != null -> visitor.visitTiered(tiered) tieredBps != null -> visitor.visitTieredBps(tieredBps) @@ -332,141 +325,133 @@ private constructor( } accept( - object : Visitor { - override fun visitUnit(unit: UnitPrice) { + object : Visitor { + override fun visitUnit(unit: Unit) { unit.validate() } - override fun visitPackagePrice(packagePrice: PackagePrice) { - packagePrice.validate() + override fun visitPackage(package_: Package) { + package_.validate() } - override fun visitMatrix(matrix: MatrixPrice) { + override fun visitMatrix(matrix: Matrix) { matrix.validate() } - override fun visitTiered(tiered: TieredPrice) { + override fun visitTiered(tiered: Tiered) { tiered.validate() } - override fun visitTieredBps(tieredBps: TieredBpsPrice) { + override fun visitTieredBps(tieredBps: TieredBps) { tieredBps.validate() } - override fun visitBps(bps: BpsPrice) { + override fun visitBps(bps: Bps) { bps.validate() } - override fun visitBulkBps(bulkBps: BulkBpsPrice) { + override fun visitBulkBps(bulkBps: BulkBps) { bulkBps.validate() } - override fun visitBulk(bulk: BulkPrice) { + override fun visitBulk(bulk: Bulk) { bulk.validate() } - override fun visitThresholdTotalAmount( - thresholdTotalAmount: ThresholdTotalAmountPrice - ) { + override fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) { thresholdTotalAmount.validate() } - override fun visitTieredPackage(tieredPackage: TieredPackagePrice) { + override fun visitTieredPackage(tieredPackage: TieredPackage) { tieredPackage.validate() } - override fun visitGroupedTiered(groupedTiered: GroupedTieredPrice) { + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { groupedTiered.validate() } - override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimumPrice) { + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { tieredWithMinimum.validate() } override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: TieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) { tieredPackageWithMinimum.validate() } override fun visitPackageWithAllocation( - packageWithAllocation: PackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) { packageWithAllocation.validate() } - override fun visitUnitWithPercent(unitWithPercent: UnitWithPercentPrice) { + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { unitWithPercent.validate() } - override fun visitMatrixWithAllocation( - matrixWithAllocation: MatrixWithAllocationPrice - ) { + override fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) { matrixWithAllocation.validate() } - override fun visitTieredWithProration( - tieredWithProration: TieredWithProrationPrice - ) { + override fun visitTieredWithProration(tieredWithProration: TieredWithProration) { tieredWithProration.validate() } - override fun visitUnitWithProration(unitWithProration: UnitWithProrationPrice) { + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { unitWithProration.validate() } - override fun visitGroupedAllocation(groupedAllocation: GroupedAllocationPrice) { + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { groupedAllocation.validate() } override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: GroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { groupedWithProratedMinimum.validate() } override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: GroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { groupedWithMeteredMinimum.validate() } override fun visitMatrixWithDisplayName( - matrixWithDisplayName: MatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) { matrixWithDisplayName.validate() } - override fun visitBulkWithProration(bulkWithProration: BulkWithProrationPrice) { + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { bulkWithProration.validate() } - override fun visitGroupedTieredPackage( - groupedTieredPackage: GroupedTieredPackagePrice - ) { + override fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) { groupedTieredPackage.validate() } override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: MaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) { maxGroupTieredPackage.validate() } override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { scalableMatrixWithUnitPricing.validate() } override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { scalableMatrixWithTieredPricing.validate() } override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: CumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) { cumulativeGroupedBulk.validate() } @@ -492,93 +477,89 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitUnit(unit: UnitPrice) = unit.validity() + override fun visitUnit(unit: Unit) = unit.validity() - override fun visitPackagePrice(packagePrice: PackagePrice) = packagePrice.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitMatrix(matrix: MatrixPrice) = matrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() - override fun visitTiered(tiered: TieredPrice) = tiered.validity() + override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitTieredBps(tieredBps: TieredBpsPrice) = tieredBps.validity() + override fun visitTieredBps(tieredBps: TieredBps) = tieredBps.validity() - override fun visitBps(bps: BpsPrice) = bps.validity() + override fun visitBps(bps: Bps) = bps.validity() - override fun visitBulkBps(bulkBps: BulkBpsPrice) = bulkBps.validity() + override fun visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() - override fun visitBulk(bulk: BulkPrice) = bulk.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() - override fun visitThresholdTotalAmount( - thresholdTotalAmount: ThresholdTotalAmountPrice - ) = thresholdTotalAmount.validity() + override fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + thresholdTotalAmount.validity() - override fun visitTieredPackage(tieredPackage: TieredPackagePrice) = + override fun visitTieredPackage(tieredPackage: TieredPackage) = tieredPackage.validity() - override fun visitGroupedTiered(groupedTiered: GroupedTieredPrice) = + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = groupedTiered.validity() - override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimumPrice) = + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = tieredWithMinimum.validity() override fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: TieredPackageWithMinimumPrice + tieredPackageWithMinimum: TieredPackageWithMinimum ) = tieredPackageWithMinimum.validity() override fun visitPackageWithAllocation( - packageWithAllocation: PackageWithAllocationPrice + packageWithAllocation: PackageWithAllocation ) = packageWithAllocation.validity() - override fun visitUnitWithPercent(unitWithPercent: UnitWithPercentPrice) = + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = unitWithPercent.validity() - override fun visitMatrixWithAllocation( - matrixWithAllocation: MatrixWithAllocationPrice - ) = matrixWithAllocation.validity() + override fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + matrixWithAllocation.validity() - override fun visitTieredWithProration( - tieredWithProration: TieredWithProrationPrice - ) = tieredWithProration.validity() + override fun visitTieredWithProration(tieredWithProration: TieredWithProration) = + tieredWithProration.validity() - override fun visitUnitWithProration(unitWithProration: UnitWithProrationPrice) = + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = unitWithProration.validity() - override fun visitGroupedAllocation(groupedAllocation: GroupedAllocationPrice) = + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = groupedAllocation.validity() override fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: GroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ) = groupedWithProratedMinimum.validity() override fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: GroupedWithMeteredMinimumPrice + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) = groupedWithMeteredMinimum.validity() override fun visitMatrixWithDisplayName( - matrixWithDisplayName: MatrixWithDisplayNamePrice + matrixWithDisplayName: MatrixWithDisplayName ) = matrixWithDisplayName.validity() - override fun visitBulkWithProration(bulkWithProration: BulkWithProrationPrice) = + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = bulkWithProration.validity() - override fun visitGroupedTieredPackage( - groupedTieredPackage: GroupedTieredPackagePrice - ) = groupedTieredPackage.validity() + override fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + groupedTieredPackage.validity() override fun visitMaxGroupTieredPackage( - maxGroupTieredPackage: MaxGroupTieredPackagePrice + maxGroupTieredPackage: MaxGroupTieredPackage ) = maxGroupTieredPackage.validity() override fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = scalableMatrixWithUnitPricing.validity() override fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = scalableMatrixWithTieredPricing.validity() override fun visitCumulativeGroupedBulk( - cumulativeGroupedBulk: CumulativeGroupedBulkPrice + cumulativeGroupedBulk: CumulativeGroupedBulk ) = cumulativeGroupedBulk.validity() override fun unknown(json: JsonValue?) = 0 @@ -590,15 +571,15 @@ private constructor( return true } - return /* spotless:off */ other is Price && unit == other.unit && packagePrice == other.packagePrice && 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 /* spotless:on */ + 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 /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, packagePrice, 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) /* spotless:on */ + 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) /* spotless:on */ override fun toString(): String = when { unit != null -> "Price{unit=$unit}" - packagePrice != null -> "Price{packagePrice=$packagePrice}" + package_ != null -> "Price{package_=$package_}" matrix != null -> "Price{matrix=$matrix}" tiered != null -> "Price{tiered=$tiered}" tieredBps != null -> "Price{tieredBps=$tieredBps}" @@ -636,175 +617,167 @@ private constructor( companion object { - @JvmStatic fun ofUnit(unit: UnitPrice) = Price(unit = unit) + @JvmStatic fun ofUnit(unit: Unit) = Price(unit = unit) - @JvmStatic - fun ofPackagePrice(packagePrice: PackagePrice) = Price(packagePrice = packagePrice) + @JvmStatic fun ofPackage(package_: Package) = Price(package_ = package_) - @JvmStatic fun ofMatrix(matrix: MatrixPrice) = Price(matrix = matrix) + @JvmStatic fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) - @JvmStatic fun ofTiered(tiered: TieredPrice) = Price(tiered = tiered) + @JvmStatic fun ofTiered(tiered: Tiered) = Price(tiered = tiered) - @JvmStatic fun ofTieredBps(tieredBps: TieredBpsPrice) = Price(tieredBps = tieredBps) + @JvmStatic fun ofTieredBps(tieredBps: TieredBps) = Price(tieredBps = tieredBps) - @JvmStatic fun ofBps(bps: BpsPrice) = Price(bps = bps) + @JvmStatic fun ofBps(bps: Bps) = Price(bps = bps) - @JvmStatic fun ofBulkBps(bulkBps: BulkBpsPrice) = Price(bulkBps = bulkBps) + @JvmStatic fun ofBulkBps(bulkBps: BulkBps) = Price(bulkBps = bulkBps) - @JvmStatic fun ofBulk(bulk: BulkPrice) = Price(bulk = bulk) + @JvmStatic fun ofBulk(bulk: Bulk) = Price(bulk = bulk) @JvmStatic - fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmountPrice) = + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = Price(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofTieredPackage(tieredPackage: TieredPackagePrice) = - Price(tieredPackage = tieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = Price(tieredPackage = tieredPackage) @JvmStatic - fun ofGroupedTiered(groupedTiered: GroupedTieredPrice) = - Price(groupedTiered = groupedTiered) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = Price(groupedTiered = groupedTiered) @JvmStatic - fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimumPrice) = + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimumPrice) = + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = Price(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic - fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocationPrice) = + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofUnitWithPercent(unitWithPercent: UnitWithPercentPrice) = + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = Price(unitWithPercent = unitWithPercent) @JvmStatic - fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocationPrice) = + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = Price(matrixWithAllocation = matrixWithAllocation) @JvmStatic - fun ofTieredWithProration(tieredWithProration: TieredWithProrationPrice) = + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = Price(tieredWithProration = tieredWithProration) @JvmStatic - fun ofUnitWithProration(unitWithProration: UnitWithProrationPrice) = + fun ofUnitWithProration(unitWithProration: UnitWithProration) = Price(unitWithProration = unitWithProration) @JvmStatic - fun ofGroupedAllocation(groupedAllocation: GroupedAllocationPrice) = + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = Price(groupedAllocation = groupedAllocation) @JvmStatic - fun ofGroupedWithProratedMinimum( - groupedWithProratedMinimum: GroupedWithProratedMinimumPrice - ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) + fun ofGroupedWithProratedMinimum(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum: GroupedWithMeteredMinimumPrice) = + fun ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayNamePrice) = + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofBulkWithProration(bulkWithProration: BulkWithProrationPrice) = + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = Price(bulkWithProration = bulkWithProration) @JvmStatic - fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackagePrice) = + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = Price(groupedTieredPackage = groupedTieredPackage) @JvmStatic - fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackagePrice) = + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = Price(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic fun ofScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic fun ofScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulkPrice) = + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = Price(cumulativeGroupedBulk = cumulativeGroupedBulk) } /** An interface that defines how to map each variant of [Price] to a value of type [T]. */ interface Visitor { - fun visitUnit(unit: UnitPrice): T + fun visitUnit(unit: Unit): T - fun visitPackagePrice(packagePrice: PackagePrice): T + fun visitPackage(package_: Package): T - fun visitMatrix(matrix: MatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitTiered(tiered: TieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitTieredBps(tieredBps: TieredBpsPrice): T + fun visitTieredBps(tieredBps: TieredBps): T - fun visitBps(bps: BpsPrice): T + fun visitBps(bps: Bps): T - fun visitBulkBps(bulkBps: BulkBpsPrice): T + fun visitBulkBps(bulkBps: BulkBps): T - fun visitBulk(bulk: BulkPrice): T + fun visitBulk(bulk: Bulk): T - fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmountPrice): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitTieredPackage(tieredPackage: TieredPackagePrice): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitGroupedTiered(groupedTiered: GroupedTieredPrice): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T - fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimumPrice): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitTieredPackageWithMinimum( - tieredPackageWithMinimum: TieredPackageWithMinimumPrice - ): T + fun visitTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum): T - fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocationPrice): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitUnitWithPercent(unitWithPercent: UnitWithPercentPrice): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocationPrice): T + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T - fun visitTieredWithProration(tieredWithProration: TieredWithProrationPrice): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitUnitWithProration(unitWithProration: UnitWithProrationPrice): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitGroupedAllocation(groupedAllocation: GroupedAllocationPrice): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T fun visitGroupedWithProratedMinimum( - groupedWithProratedMinimum: GroupedWithProratedMinimumPrice + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T - fun visitGroupedWithMeteredMinimum( - groupedWithMeteredMinimum: GroupedWithMeteredMinimumPrice - ): T + fun visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum: GroupedWithMeteredMinimum): T - fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayNamePrice): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitBulkWithProration(bulkWithProration: BulkWithProrationPrice): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T - fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackagePrice): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackagePrice): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T fun visitScalableMatrixWithUnitPricing( - scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T fun visitScalableMatrixWithTieredPricing( - scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulkPrice): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -828,148 +801,142 @@ private constructor( when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(unit = it, _json = json) } ?: Price(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Price(packagePrice = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(package_ = it, _json = json) } ?: Price(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(matrix = it, _json = json) } ?: Price(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(tiered = it, _json = json) } ?: Price(_json = json) } "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(tieredBps = it, _json = json) } ?: Price(_json = json) } "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(bps = it, _json = json) } ?: Price(_json = json) } "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(bulkBps = it, _json = json) } ?: Price(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(bulk = it, _json = json) } ?: Price(_json = json) } "threshold_total_amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(thresholdTotalAmount = it, _json = json) } ?: Price(_json = json) } "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(tieredPackage = it, _json = json) } ?: Price(_json = json) } "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(groupedTiered = it, _json = json) } ?: Price(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(tieredWithMinimum = it, _json = json) } ?: Price(_json = json) } "tiered_package_with_minimum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(tieredPackageWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredPackageWithMinimum = it, _json = json) + } ?: Price(_json = json) } "package_with_allocation" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(packageWithAllocation = it, _json = json) } ?: Price(_json = json) } "unit_with_percent" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(unitWithPercent = it, _json = json) } ?: Price(_json = json) } "matrix_with_allocation" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } "tiered_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } "unit_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(unitWithProration = it, _json = json) } ?: Price(_json = json) } "grouped_allocation" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(groupedAllocation = it, _json = json) } ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(groupedWithProratedMinimum = it, _json = json) } - ?: Price(_json = json) + 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) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedWithMeteredMinimum = it, _json = json) + } ?: Price(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } "bulk_with_proration" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(bulkWithProration = it, _json = json) } ?: Price(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(groupedTieredPackage = it, _json = json) } ?: Price(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(maxGroupTieredPackage = it, _json = json) } ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) + return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) + return tryDeserialize(node, jacksonTypeRef()) ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } @@ -988,7 +955,7 @@ private constructor( ) { when { value.unit != null -> generator.writeObject(value.unit) - value.packagePrice != null -> generator.writeObject(value.packagePrice) + 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) @@ -1034,7 +1001,7 @@ private constructor( } } - class UnitPrice + class Unit private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -1054,7 +1021,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -1109,9 +1076,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -1272,10 +1237,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -1465,15 +1435,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -1535,7 +1496,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnitPrice]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java @@ -1557,7 +1518,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -1567,7 +1527,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UnitPrice]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -1588,7 +1548,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -1598,32 +1558,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitPrice: UnitPrice) = apply { - id = unitPrice.id - billableMetric = unitPrice.billableMetric - billingCycleConfiguration = unitPrice.billingCycleConfiguration - cadence = unitPrice.cadence - conversionRate = unitPrice.conversionRate - createdAt = unitPrice.createdAt - creditAllocation = unitPrice.creditAllocation - currency = unitPrice.currency - discount = unitPrice.discount - externalPriceId = unitPrice.externalPriceId - fixedPriceQuantity = unitPrice.fixedPriceQuantity - invoicingCycleConfiguration = unitPrice.invoicingCycleConfiguration - item = unitPrice.item - maximum = unitPrice.maximum - maximumAmount = unitPrice.maximumAmount - metadata = unitPrice.metadata - minimum = unitPrice.minimum - minimumAmount = unitPrice.minimumAmount - modelType = unitPrice.modelType - name = unitPrice.name - planPhaseOrder = unitPrice.planPhaseOrder - priceType = unitPrice.priceType - unitConfig = unitPrice.unitConfig - dimensionalPriceConfiguration = unitPrice.dimensionalPriceConfiguration - additionalProperties = unitPrice.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + id = unit.id + billableMetric = unit.billableMetric + billingCycleConfiguration = unit.billingCycleConfiguration + cadence = unit.cadence + conversionRate = unit.conversionRate + createdAt = unit.createdAt + creditAllocation = unit.creditAllocation + currency = unit.currency + discount = unit.discount + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + item = unit.item + maximum = unit.maximum + maximumAmount = unit.maximumAmount + metadata = unit.metadata + minimum = unit.minimum + minimumAmount = unit.minimumAmount + modelType = unit.modelType + name = unit.name + planPhaseOrder = unit.planPhaseOrder + priceType = unit.priceType + unitConfig = unit.unitConfig + dimensionalPriceConfiguration = unit.dimensionalPriceConfiguration + additionalProperties = unit.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -1954,16 +1914,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -2068,7 +2031,7 @@ private constructor( } /** - * Returns an immutable instance of [UnitPrice]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2092,7 +2055,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -2101,8 +2063,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnitPrice = - UnitPrice( + fun build(): Unit = + Unit( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -2121,7 +2083,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -2133,7 +2095,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitPrice = apply { + fun validate(): Unit = apply { if (validated) { return@apply } @@ -2156,7 +2118,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -2199,7 +2165,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + @@ -4178,129 +4144,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT = of("unit") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT - } - - /** - * 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 { - UNIT, - /** - * 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) { - UNIT -> Value.UNIT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - UNIT -> Known.UNIT - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4834,7 +4677,7 @@ private constructor( return true } - return /* spotless:off */ other is UnitPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && unitConfig == other.unitConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Unit && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && unitConfig == other.unitConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4844,10 +4687,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Unit{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, unitConfig=$unitConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class PackagePrice + class Package private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -4867,7 +4710,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageConfig: JsonField, private val planPhaseOrder: JsonField, @@ -4922,9 +4765,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("package_config") @ExcludeMissing @@ -5085,10 +4926,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -5278,15 +5124,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -5349,7 +5186,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [PackagePrice]. + * Returns a mutable builder for constructing an instance of [Package]. * * The following fields are required: * ```java @@ -5371,7 +5208,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .packageConfig() * .planPhaseOrder() @@ -5381,7 +5217,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PackagePrice]. */ + /** A builder for [Package]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -5402,7 +5238,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package") private var name: JsonField? = null private var packageConfig: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -5412,32 +5248,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(packagePrice: PackagePrice) = apply { - id = packagePrice.id - billableMetric = packagePrice.billableMetric - billingCycleConfiguration = packagePrice.billingCycleConfiguration - cadence = packagePrice.cadence - conversionRate = packagePrice.conversionRate - createdAt = packagePrice.createdAt - creditAllocation = packagePrice.creditAllocation - currency = packagePrice.currency - discount = packagePrice.discount - externalPriceId = packagePrice.externalPriceId - fixedPriceQuantity = packagePrice.fixedPriceQuantity - invoicingCycleConfiguration = packagePrice.invoicingCycleConfiguration - item = packagePrice.item - maximum = packagePrice.maximum - maximumAmount = packagePrice.maximumAmount - metadata = packagePrice.metadata - minimum = packagePrice.minimum - minimumAmount = packagePrice.minimumAmount - modelType = packagePrice.modelType - name = packagePrice.name - packageConfig = packagePrice.packageConfig - planPhaseOrder = packagePrice.planPhaseOrder - priceType = packagePrice.priceType - dimensionalPriceConfiguration = packagePrice.dimensionalPriceConfiguration - additionalProperties = packagePrice.additionalProperties.toMutableMap() + internal fun from(package_: Package) = apply { + id = package_.id + billableMetric = package_.billableMetric + billingCycleConfiguration = package_.billingCycleConfiguration + cadence = package_.cadence + conversionRate = package_.conversionRate + 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 + dimensionalPriceConfiguration = package_.dimensionalPriceConfiguration + additionalProperties = package_.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -5768,16 +5604,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -5883,7 +5722,7 @@ private constructor( } /** - * Returns an immutable instance of [PackagePrice]. + * Returns an immutable instance of [Package]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -5907,7 +5746,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .packageConfig() * .planPhaseOrder() @@ -5916,8 +5754,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PackagePrice = - PackagePrice( + fun build(): Package = + Package( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -5936,7 +5774,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageConfig", packageConfig), checkRequired("planPhaseOrder", planPhaseOrder), @@ -5948,7 +5786,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PackagePrice = apply { + fun validate(): Package = apply { if (validated) { return@apply } @@ -5971,7 +5809,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageConfig().validate() planPhaseOrder() @@ -6014,7 +5856,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -7993,129 +7835,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * 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 { - PACKAGE, - /** - * 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) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - 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 PackageConfig private constructor( private val packageAmount: JsonField, @@ -8699,7 +8418,7 @@ private constructor( return true } - return /* spotless:off */ other is PackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Package && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -8709,10 +8428,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Package{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class MatrixPrice + class Matrix private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -8733,7 +8452,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -8790,9 +8509,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -8956,10 +8673,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -9153,15 +8875,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -9214,7 +8927,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MatrixPrice]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java @@ -9237,7 +8950,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -9246,7 +8958,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixPrice]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -9268,7 +8980,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -9277,32 +8989,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixPrice: MatrixPrice) = apply { - id = matrixPrice.id - billableMetric = matrixPrice.billableMetric - billingCycleConfiguration = matrixPrice.billingCycleConfiguration - cadence = matrixPrice.cadence - conversionRate = matrixPrice.conversionRate - createdAt = matrixPrice.createdAt - creditAllocation = matrixPrice.creditAllocation - currency = matrixPrice.currency - discount = matrixPrice.discount - externalPriceId = matrixPrice.externalPriceId - fixedPriceQuantity = matrixPrice.fixedPriceQuantity - invoicingCycleConfiguration = matrixPrice.invoicingCycleConfiguration - item = matrixPrice.item - matrixConfig = matrixPrice.matrixConfig - maximum = matrixPrice.maximum - maximumAmount = matrixPrice.maximumAmount - metadata = matrixPrice.metadata - minimum = matrixPrice.minimum - minimumAmount = matrixPrice.minimumAmount - modelType = matrixPrice.modelType - name = matrixPrice.name - planPhaseOrder = matrixPrice.planPhaseOrder - priceType = matrixPrice.priceType - dimensionalPriceConfiguration = matrixPrice.dimensionalPriceConfiguration - additionalProperties = matrixPrice.additionalProperties.toMutableMap() + internal fun from(matrix: Matrix) = apply { + id = matrix.id + billableMetric = matrix.billableMetric + billingCycleConfiguration = matrix.billingCycleConfiguration + cadence = matrix.cadence + conversionRate = matrix.conversionRate + 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 + dimensionalPriceConfiguration = matrix.dimensionalPriceConfiguration + additionalProperties = matrix.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -9646,16 +9358,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -9747,7 +9462,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixPrice]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -9772,7 +9487,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -9780,8 +9494,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixPrice = - MatrixPrice( + fun build(): Matrix = + Matrix( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -9801,7 +9515,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -9812,7 +9526,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixPrice = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -9836,7 +9550,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -9879,7 +9597,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -12383,129 +12101,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -12869,7 +12464,7 @@ private constructor( return true } - return /* spotless:off */ other is MatrixPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Matrix && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -12879,10 +12474,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Matrix{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredPrice + class Tiered private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -12902,7 +12497,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -12957,9 +12552,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -13120,10 +12713,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -13313,15 +12911,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -13384,7 +12973,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredPrice]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java @@ -13406,7 +12995,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -13416,7 +13004,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [TieredPrice]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -13437,7 +13025,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -13447,32 +13035,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPrice: TieredPrice) = apply { - id = tieredPrice.id - billableMetric = tieredPrice.billableMetric - billingCycleConfiguration = tieredPrice.billingCycleConfiguration - cadence = tieredPrice.cadence - conversionRate = tieredPrice.conversionRate - createdAt = tieredPrice.createdAt - creditAllocation = tieredPrice.creditAllocation - currency = tieredPrice.currency - discount = tieredPrice.discount - externalPriceId = tieredPrice.externalPriceId - fixedPriceQuantity = tieredPrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredPrice.invoicingCycleConfiguration - item = tieredPrice.item - maximum = tieredPrice.maximum - maximumAmount = tieredPrice.maximumAmount - metadata = tieredPrice.metadata - minimum = tieredPrice.minimum - minimumAmount = tieredPrice.minimumAmount - modelType = tieredPrice.modelType - name = tieredPrice.name - planPhaseOrder = tieredPrice.planPhaseOrder - priceType = tieredPrice.priceType - tieredConfig = tieredPrice.tieredConfig - dimensionalPriceConfiguration = tieredPrice.dimensionalPriceConfiguration - additionalProperties = tieredPrice.additionalProperties.toMutableMap() + internal fun from(tiered: Tiered) = apply { + id = tiered.id + billableMetric = tiered.billableMetric + billingCycleConfiguration = tiered.billingCycleConfiguration + cadence = tiered.cadence + conversionRate = tiered.conversionRate + 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 + tieredConfig = tiered.tieredConfig + dimensionalPriceConfiguration = tiered.dimensionalPriceConfiguration + additionalProperties = tiered.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -13803,16 +13391,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -13917,7 +13508,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredPrice]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -13941,7 +13532,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -13950,8 +13540,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredPrice = - TieredPrice( + fun build(): Tiered = + Tiered( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -13970,7 +13560,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -13982,7 +13572,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredPrice = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } @@ -14005,7 +13595,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -14048,7 +13642,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + @@ -16027,129 +15621,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * 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, - /** - * 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 -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.TIERED - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -16957,7 +16428,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tiered && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredConfig == other.tieredConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -16967,10 +16438,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Tiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredConfig=$tieredConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredBpsPrice + class TieredBps private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -16990,7 +16461,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -17045,9 +16516,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -17208,10 +16677,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -17401,15 +16875,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -17472,7 +16937,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredBpsPrice]. + * Returns a mutable builder for constructing an instance of [TieredBps]. * * The following fields are required: * ```java @@ -17494,7 +16959,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -17504,7 +16968,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [TieredBpsPrice]. */ + /** A builder for [TieredBps]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -17525,7 +16989,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_bps") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -17535,32 +16999,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredBpsPrice: TieredBpsPrice) = apply { - id = tieredBpsPrice.id - billableMetric = tieredBpsPrice.billableMetric - billingCycleConfiguration = tieredBpsPrice.billingCycleConfiguration - cadence = tieredBpsPrice.cadence - conversionRate = tieredBpsPrice.conversionRate - createdAt = tieredBpsPrice.createdAt - creditAllocation = tieredBpsPrice.creditAllocation - currency = tieredBpsPrice.currency - discount = tieredBpsPrice.discount - externalPriceId = tieredBpsPrice.externalPriceId - fixedPriceQuantity = tieredBpsPrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredBpsPrice.invoicingCycleConfiguration - item = tieredBpsPrice.item - maximum = tieredBpsPrice.maximum - maximumAmount = tieredBpsPrice.maximumAmount - metadata = tieredBpsPrice.metadata - minimum = tieredBpsPrice.minimum - minimumAmount = tieredBpsPrice.minimumAmount - modelType = tieredBpsPrice.modelType - name = tieredBpsPrice.name - planPhaseOrder = tieredBpsPrice.planPhaseOrder - priceType = tieredBpsPrice.priceType - tieredBpsConfig = tieredBpsPrice.tieredBpsConfig - dimensionalPriceConfiguration = tieredBpsPrice.dimensionalPriceConfiguration - additionalProperties = tieredBpsPrice.additionalProperties.toMutableMap() + internal fun from(tieredBps: TieredBps) = apply { + id = tieredBps.id + billableMetric = tieredBps.billableMetric + billingCycleConfiguration = tieredBps.billingCycleConfiguration + cadence = tieredBps.cadence + conversionRate = tieredBps.conversionRate + 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 + tieredBpsConfig = tieredBps.tieredBpsConfig + dimensionalPriceConfiguration = tieredBps.dimensionalPriceConfiguration + additionalProperties = tieredBps.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -17891,16 +17355,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -18006,7 +17473,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredBpsPrice]. + * Returns an immutable instance of [TieredBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -18030,7 +17497,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -18039,8 +17505,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredBpsPrice = - TieredBpsPrice( + fun build(): TieredBps = + TieredBps( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -18059,7 +17525,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -18071,7 +17537,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredBpsPrice = apply { + fun validate(): TieredBps = apply { if (validated) { return@apply } @@ -18094,7 +17560,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -18137,7 +17607,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + @@ -20116,129 +19586,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @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() - } - class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -21092,7 +20439,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredBpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredBpsConfig == other.tieredBpsConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBps && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredBpsConfig == other.tieredBpsConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -21102,10 +20449,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredBpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredBpsConfig=$tieredBpsConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredBps{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredBpsConfig=$tieredBpsConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class BpsPrice + class Bps private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -21126,7 +20473,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -21183,9 +20530,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -21349,10 +20694,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -21545,15 +20895,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -21606,7 +20947,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BpsPrice]. + * Returns a mutable builder for constructing an instance of [Bps]. * * The following fields are required: * ```java @@ -21629,7 +20970,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -21638,7 +20978,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BpsPrice]. */ + /** A builder for [Bps]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -21660,7 +21000,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bps") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -21669,32 +21009,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bpsPrice: BpsPrice) = apply { - id = bpsPrice.id - billableMetric = bpsPrice.billableMetric - billingCycleConfiguration = bpsPrice.billingCycleConfiguration - bpsConfig = bpsPrice.bpsConfig - cadence = bpsPrice.cadence - conversionRate = bpsPrice.conversionRate - createdAt = bpsPrice.createdAt - creditAllocation = bpsPrice.creditAllocation - currency = bpsPrice.currency - discount = bpsPrice.discount - externalPriceId = bpsPrice.externalPriceId - fixedPriceQuantity = bpsPrice.fixedPriceQuantity - invoicingCycleConfiguration = bpsPrice.invoicingCycleConfiguration - item = bpsPrice.item - maximum = bpsPrice.maximum - maximumAmount = bpsPrice.maximumAmount - metadata = bpsPrice.metadata - minimum = bpsPrice.minimum - minimumAmount = bpsPrice.minimumAmount - modelType = bpsPrice.modelType - name = bpsPrice.name - planPhaseOrder = bpsPrice.planPhaseOrder - priceType = bpsPrice.priceType - dimensionalPriceConfiguration = bpsPrice.dimensionalPriceConfiguration - additionalProperties = bpsPrice.additionalProperties.toMutableMap() + internal fun from(bps: Bps) = apply { + id = bps.id + billableMetric = bps.billableMetric + billingCycleConfiguration = bps.billingCycleConfiguration + bpsConfig = bps.bpsConfig + cadence = bps.cadence + conversionRate = bps.conversionRate + 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 + dimensionalPriceConfiguration = bps.dimensionalPriceConfiguration + additionalProperties = bps.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -22036,16 +21376,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -22137,7 +21480,7 @@ private constructor( } /** - * Returns an immutable instance of [BpsPrice]. + * Returns an immutable instance of [Bps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -22162,7 +21505,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -22170,8 +21512,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BpsPrice = - BpsPrice( + fun build(): Bps = + Bps( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -22191,7 +21533,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -22202,7 +21544,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BpsPrice = apply { + fun validate(): Bps = apply { if (validated) { return@apply } @@ -22226,7 +21568,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -22269,7 +21615,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + @@ -24459,129 +23805,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @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() - } - class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -24945,7 +24168,7 @@ private constructor( return true } - return /* spotless:off */ other is BpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bpsConfig == other.bpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bps && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bpsConfig == other.bpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -24955,10 +24178,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bpsConfig=$bpsConfig, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Bps{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bpsConfig=$bpsConfig, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class BulkBpsPrice + class BulkBps private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -24979,7 +24202,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -25036,9 +24259,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -25202,10 +24423,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -25399,15 +24625,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -25460,7 +24677,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkBpsPrice]. + * Returns a mutable builder for constructing an instance of [BulkBps]. * * The following fields are required: * ```java @@ -25483,7 +24700,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -25492,7 +24708,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BulkBpsPrice]. */ + /** A builder for [BulkBps]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -25514,7 +24730,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_bps") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -25523,32 +24739,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkBpsPrice: BulkBpsPrice) = apply { - id = bulkBpsPrice.id - billableMetric = bulkBpsPrice.billableMetric - billingCycleConfiguration = bulkBpsPrice.billingCycleConfiguration - bulkBpsConfig = bulkBpsPrice.bulkBpsConfig - cadence = bulkBpsPrice.cadence - conversionRate = bulkBpsPrice.conversionRate - createdAt = bulkBpsPrice.createdAt - creditAllocation = bulkBpsPrice.creditAllocation - currency = bulkBpsPrice.currency - discount = bulkBpsPrice.discount - externalPriceId = bulkBpsPrice.externalPriceId - fixedPriceQuantity = bulkBpsPrice.fixedPriceQuantity - invoicingCycleConfiguration = bulkBpsPrice.invoicingCycleConfiguration - item = bulkBpsPrice.item - maximum = bulkBpsPrice.maximum - maximumAmount = bulkBpsPrice.maximumAmount - metadata = bulkBpsPrice.metadata - minimum = bulkBpsPrice.minimum - minimumAmount = bulkBpsPrice.minimumAmount - modelType = bulkBpsPrice.modelType - name = bulkBpsPrice.name - planPhaseOrder = bulkBpsPrice.planPhaseOrder - priceType = bulkBpsPrice.priceType - dimensionalPriceConfiguration = bulkBpsPrice.dimensionalPriceConfiguration - additionalProperties = bulkBpsPrice.additionalProperties.toMutableMap() + internal fun from(bulkBps: BulkBps) = apply { + id = bulkBps.id + billableMetric = bulkBps.billableMetric + billingCycleConfiguration = bulkBps.billingCycleConfiguration + bulkBpsConfig = bulkBps.bulkBpsConfig + cadence = bulkBps.cadence + conversionRate = bulkBps.conversionRate + 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 + dimensionalPriceConfiguration = bulkBps.dimensionalPriceConfiguration + additionalProperties = bulkBps.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -25893,16 +25109,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -25994,7 +25213,7 @@ private constructor( } /** - * Returns an immutable instance of [BulkBpsPrice]. + * Returns an immutable instance of [BulkBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -26019,7 +25238,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -26027,8 +25245,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkBpsPrice = - BulkBpsPrice( + fun build(): BulkBps = + BulkBps( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -26048,7 +25266,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -26059,7 +25277,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkBpsPrice = apply { + fun validate(): BulkBps = apply { if (validated) { return@apply } @@ -26083,7 +25301,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -26126,7 +25348,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + @@ -28550,129 +27772,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -29036,7 +28135,7 @@ private constructor( return true } - return /* spotless:off */ other is BulkBpsPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBps && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -29046,10 +28145,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkBpsPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkBps{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class BulkPrice + class Bulk private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -29070,7 +28169,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -29127,9 +28226,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -29293,10 +28390,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -29489,15 +28591,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -29550,7 +28643,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkPrice]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java @@ -29573,7 +28666,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -29582,7 +28674,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BulkPrice]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -29604,7 +28696,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -29613,32 +28705,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkPrice: BulkPrice) = apply { - id = bulkPrice.id - billableMetric = bulkPrice.billableMetric - billingCycleConfiguration = bulkPrice.billingCycleConfiguration - bulkConfig = bulkPrice.bulkConfig - cadence = bulkPrice.cadence - conversionRate = bulkPrice.conversionRate - createdAt = bulkPrice.createdAt - creditAllocation = bulkPrice.creditAllocation - currency = bulkPrice.currency - discount = bulkPrice.discount - externalPriceId = bulkPrice.externalPriceId - fixedPriceQuantity = bulkPrice.fixedPriceQuantity - invoicingCycleConfiguration = bulkPrice.invoicingCycleConfiguration - item = bulkPrice.item - maximum = bulkPrice.maximum - maximumAmount = bulkPrice.maximumAmount - metadata = bulkPrice.metadata - minimum = bulkPrice.minimum - minimumAmount = bulkPrice.minimumAmount - modelType = bulkPrice.modelType - name = bulkPrice.name - planPhaseOrder = bulkPrice.planPhaseOrder - priceType = bulkPrice.priceType - dimensionalPriceConfiguration = bulkPrice.dimensionalPriceConfiguration - additionalProperties = bulkPrice.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + id = bulk.id + billableMetric = bulk.billableMetric + billingCycleConfiguration = bulk.billingCycleConfiguration + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + conversionRate = bulk.conversionRate + 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 + dimensionalPriceConfiguration = bulk.dimensionalPriceConfiguration + additionalProperties = bulk.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -29982,16 +29074,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -30083,7 +29178,7 @@ private constructor( } /** - * Returns an immutable instance of [BulkPrice]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -30108,7 +29203,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -30116,8 +29210,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkPrice = - BulkPrice( + fun build(): Bulk = + Bulk( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -30137,7 +29231,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -30148,7 +29242,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkPrice = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -30172,7 +29266,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -30215,7 +29313,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -32599,129 +31697,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -33085,7 +32060,7 @@ private constructor( return true } - return /* spotless:off */ other is BulkPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkConfig == other.bulkConfig && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkConfig == other.bulkConfig && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -33095,10 +32070,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "Bulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkConfig=$bulkConfig, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class ThresholdTotalAmountPrice + class ThresholdTotalAmount private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -33118,7 +32093,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -33173,9 +32148,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -33336,10 +32309,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -33530,15 +32508,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -33602,8 +32571,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [ThresholdTotalAmountPrice]. + * Returns a mutable builder for constructing an instance of [ThresholdTotalAmount]. * * The following fields are required: * ```java @@ -33625,7 +32593,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -33635,7 +32602,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ThresholdTotalAmountPrice]. */ + /** A builder for [ThresholdTotalAmount]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -33656,7 +32623,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -33666,33 +32633,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(thresholdTotalAmountPrice: ThresholdTotalAmountPrice) = apply { - id = thresholdTotalAmountPrice.id - billableMetric = thresholdTotalAmountPrice.billableMetric - billingCycleConfiguration = thresholdTotalAmountPrice.billingCycleConfiguration - cadence = thresholdTotalAmountPrice.cadence - conversionRate = thresholdTotalAmountPrice.conversionRate - createdAt = thresholdTotalAmountPrice.createdAt - creditAllocation = thresholdTotalAmountPrice.creditAllocation - currency = thresholdTotalAmountPrice.currency - discount = thresholdTotalAmountPrice.discount - externalPriceId = thresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = thresholdTotalAmountPrice.fixedPriceQuantity - invoicingCycleConfiguration = thresholdTotalAmountPrice.invoicingCycleConfiguration - item = thresholdTotalAmountPrice.item - maximum = thresholdTotalAmountPrice.maximum - maximumAmount = thresholdTotalAmountPrice.maximumAmount - metadata = thresholdTotalAmountPrice.metadata - minimum = thresholdTotalAmountPrice.minimum - minimumAmount = thresholdTotalAmountPrice.minimumAmount - modelType = thresholdTotalAmountPrice.modelType - name = thresholdTotalAmountPrice.name - planPhaseOrder = thresholdTotalAmountPrice.planPhaseOrder - priceType = thresholdTotalAmountPrice.priceType - thresholdTotalAmountConfig = thresholdTotalAmountPrice.thresholdTotalAmountConfig - dimensionalPriceConfiguration = - thresholdTotalAmountPrice.dimensionalPriceConfiguration - additionalProperties = thresholdTotalAmountPrice.additionalProperties.toMutableMap() + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + id = thresholdTotalAmount.id + billableMetric = thresholdTotalAmount.billableMetric + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + cadence = thresholdTotalAmount.cadence + conversionRate = thresholdTotalAmount.conversionRate + 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 + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + dimensionalPriceConfiguration = thresholdTotalAmount.dimensionalPriceConfiguration + additionalProperties = thresholdTotalAmount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -34023,16 +32989,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -34138,7 +33107,7 @@ private constructor( } /** - * Returns an immutable instance of [ThresholdTotalAmountPrice]. + * Returns an immutable instance of [ThresholdTotalAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -34162,7 +33131,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -34171,8 +33139,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): ThresholdTotalAmountPrice = - ThresholdTotalAmountPrice( + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -34191,7 +33159,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -34203,7 +33171,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ThresholdTotalAmountPrice = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } @@ -34226,7 +33194,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -34269,7 +33241,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -36248,7 +35220,7 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : + class PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -36263,29 +35235,33 @@ private constructor( companion object { - @JvmField val THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") + @JvmField val USAGE_PRICE = of("usage_price") + + @JvmField val FIXED_PRICE = of("fixed_price") - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) + @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) } - /** An enum containing [ModelType]'s known values. */ + /** An enum containing [PriceType]'s known values. */ enum class Known { - THRESHOLD_TOTAL_AMOUNT + USAGE_PRICE, + FIXED_PRICE, } /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [ModelType] can contain an unknown value in a couple of cases: + * 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 { - THRESHOLD_TOTAL_AMOUNT, + USAGE_PRICE, + FIXED_PRICE, /** - * An enum member indicating that [ModelType] was instantiated with an unknown + * An enum member indicating that [PriceType] was instantiated with an unknown * value. */ _UNKNOWN, @@ -36300,7 +35276,8 @@ private constructor( */ fun value(): Value = when (this) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT + USAGE_PRICE -> Value.USAGE_PRICE + FIXED_PRICE -> Value.FIXED_PRICE else -> Value._UNKNOWN } @@ -36315,8 +35292,9 @@ private constructor( */ fun known(): Known = when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - else -> throw OrbInvalidDataException("Unknown ModelType: $value") + USAGE_PRICE -> Known.USAGE_PRICE + FIXED_PRICE -> Known.FIXED_PRICE + else -> throw OrbInvalidDataException("Unknown PriceType: $value") } /** @@ -36333,136 +35311,7 @@ private constructor( 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 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") - - @JvmStatic fun of(value: String) = PriceType(JsonField.of(value)) - } - - /** An enum containing [PriceType]'s known values. */ - enum class Known { - USAGE_PRICE, - FIXED_PRICE, - } - - /** - * An enum containing [PriceType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PriceType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USAGE_PRICE, - FIXED_PRICE, - /** - * An enum member indicating that [PriceType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USAGE_PRICE -> Value.USAGE_PRICE - FIXED_PRICE -> Value.FIXED_PRICE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USAGE_PRICE -> Known.USAGE_PRICE - FIXED_PRICE -> Known.FIXED_PRICE - else -> throw OrbInvalidDataException("Unknown PriceType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { OrbInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PriceType = apply { + fun validate(): PriceType = apply { if (validated) { return@apply } @@ -36844,7 +35693,7 @@ private constructor( return true } - return /* spotless:off */ other is ThresholdTotalAmountPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmount && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -36854,10 +35703,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ThresholdTotalAmountPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredPackagePrice + class TieredPackage private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -36877,7 +35726,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -36932,9 +35781,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -37095,10 +35942,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -37289,15 +36141,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -37360,7 +36203,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [TieredPackage]. * * The following fields are required: * ```java @@ -37382,7 +36225,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -37392,7 +36234,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [TieredPackagePrice]. */ + /** A builder for [TieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -37413,7 +36255,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -37423,32 +36265,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackagePrice: TieredPackagePrice) = apply { - id = tieredPackagePrice.id - billableMetric = tieredPackagePrice.billableMetric - billingCycleConfiguration = tieredPackagePrice.billingCycleConfiguration - cadence = tieredPackagePrice.cadence - conversionRate = tieredPackagePrice.conversionRate - createdAt = tieredPackagePrice.createdAt - creditAllocation = tieredPackagePrice.creditAllocation - currency = tieredPackagePrice.currency - discount = tieredPackagePrice.discount - externalPriceId = tieredPackagePrice.externalPriceId - fixedPriceQuantity = tieredPackagePrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredPackagePrice.invoicingCycleConfiguration - item = tieredPackagePrice.item - maximum = tieredPackagePrice.maximum - maximumAmount = tieredPackagePrice.maximumAmount - metadata = tieredPackagePrice.metadata - minimum = tieredPackagePrice.minimum - minimumAmount = tieredPackagePrice.minimumAmount - modelType = tieredPackagePrice.modelType - name = tieredPackagePrice.name - planPhaseOrder = tieredPackagePrice.planPhaseOrder - priceType = tieredPackagePrice.priceType - tieredPackageConfig = tieredPackagePrice.tieredPackageConfig - dimensionalPriceConfiguration = tieredPackagePrice.dimensionalPriceConfiguration - additionalProperties = tieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(tieredPackage: TieredPackage) = apply { + id = tieredPackage.id + billableMetric = tieredPackage.billableMetric + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + cadence = tieredPackage.cadence + conversionRate = tieredPackage.conversionRate + 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 + tieredPackageConfig = tieredPackage.tieredPackageConfig + dimensionalPriceConfiguration = tieredPackage.dimensionalPriceConfiguration + additionalProperties = tieredPackage.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -37779,16 +36621,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -37894,7 +36739,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredPackagePrice]. + * Returns an immutable instance of [TieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -37918,7 +36763,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -37927,8 +36771,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredPackagePrice = - TieredPackagePrice( + fun build(): TieredPackage = + TieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -37947,7 +36791,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -37959,7 +36803,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredPackagePrice = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } @@ -37982,7 +36826,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -38025,7 +36873,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -40004,129 +38852,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * 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_PACKAGE, - /** - * 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_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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_PACKAGE -> Known.TIERED_PACKAGE - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -40598,7 +39323,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredPackageConfig == other.tieredPackageConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -40608,10 +39333,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredPackageConfig=$tieredPackageConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedTieredPrice + class GroupedTiered private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -40632,7 +39357,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -40689,9 +39414,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -40856,10 +39579,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -41053,15 +39781,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -41114,7 +39833,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedTieredPrice]. + * Returns a mutable builder for constructing an instance of [GroupedTiered]. * * The following fields are required: * ```java @@ -41137,7 +39856,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -41146,7 +39864,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedTieredPrice]. */ + /** A builder for [GroupedTiered]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -41168,7 +39886,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -41177,32 +39895,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedTieredPrice: GroupedTieredPrice) = apply { - id = groupedTieredPrice.id - billableMetric = groupedTieredPrice.billableMetric - billingCycleConfiguration = groupedTieredPrice.billingCycleConfiguration - cadence = groupedTieredPrice.cadence - conversionRate = groupedTieredPrice.conversionRate - createdAt = groupedTieredPrice.createdAt - creditAllocation = groupedTieredPrice.creditAllocation - currency = groupedTieredPrice.currency - discount = groupedTieredPrice.discount - externalPriceId = groupedTieredPrice.externalPriceId - fixedPriceQuantity = groupedTieredPrice.fixedPriceQuantity - groupedTieredConfig = groupedTieredPrice.groupedTieredConfig - invoicingCycleConfiguration = groupedTieredPrice.invoicingCycleConfiguration - item = groupedTieredPrice.item - maximum = groupedTieredPrice.maximum - maximumAmount = groupedTieredPrice.maximumAmount - metadata = groupedTieredPrice.metadata - minimum = groupedTieredPrice.minimum - minimumAmount = groupedTieredPrice.minimumAmount - modelType = groupedTieredPrice.modelType - name = groupedTieredPrice.name - planPhaseOrder = groupedTieredPrice.planPhaseOrder - priceType = groupedTieredPrice.priceType - dimensionalPriceConfiguration = groupedTieredPrice.dimensionalPriceConfiguration - additionalProperties = groupedTieredPrice.additionalProperties.toMutableMap() + internal fun from(groupedTiered: GroupedTiered) = apply { + id = groupedTiered.id + billableMetric = groupedTiered.billableMetric + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + cadence = groupedTiered.cadence + conversionRate = groupedTiered.conversionRate + 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 + dimensionalPriceConfiguration = groupedTiered.dimensionalPriceConfiguration + additionalProperties = groupedTiered.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -41547,16 +40265,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -41648,7 +40369,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredPrice]. + * Returns an immutable instance of [GroupedTiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -41673,7 +40394,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -41681,8 +40401,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTieredPrice = - GroupedTieredPrice( + fun build(): GroupedTiered = + GroupedTiered( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -41702,7 +40422,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -41713,7 +40433,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTieredPrice = apply { + fun validate(): GroupedTiered = apply { if (validated) { return@apply } @@ -41737,7 +40457,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -41780,7 +40504,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -43866,129 +42590,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED = of("grouped_tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED - } - - /** - * 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 { - GROUPED_TIERED, - /** - * 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) { - GROUPED_TIERED -> Value.GROUPED_TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED -> Known.GROUPED_TIERED - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -44352,7 +42953,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTiered && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -44362,10 +42963,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTiered{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredWithMinimumPrice + class TieredWithMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -44385,7 +42986,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -44440,9 +43041,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -44603,10 +43202,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -44797,15 +43401,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -44868,7 +43463,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredWithMinimumPrice]. + * Returns a mutable builder for constructing an instance of [TieredWithMinimum]. * * The following fields are required: * ```java @@ -44890,7 +43485,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -44900,7 +43494,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithMinimumPrice]. */ + /** A builder for [TieredWithMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -44921,7 +43515,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -44931,32 +43525,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithMinimumPrice: TieredWithMinimumPrice) = apply { - id = tieredWithMinimumPrice.id - billableMetric = tieredWithMinimumPrice.billableMetric - billingCycleConfiguration = tieredWithMinimumPrice.billingCycleConfiguration - cadence = tieredWithMinimumPrice.cadence - conversionRate = tieredWithMinimumPrice.conversionRate - createdAt = tieredWithMinimumPrice.createdAt - creditAllocation = tieredWithMinimumPrice.creditAllocation - currency = tieredWithMinimumPrice.currency - discount = tieredWithMinimumPrice.discount - externalPriceId = tieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = tieredWithMinimumPrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredWithMinimumPrice.invoicingCycleConfiguration - item = tieredWithMinimumPrice.item - maximum = tieredWithMinimumPrice.maximum - maximumAmount = tieredWithMinimumPrice.maximumAmount - metadata = tieredWithMinimumPrice.metadata - minimum = tieredWithMinimumPrice.minimum - minimumAmount = tieredWithMinimumPrice.minimumAmount - modelType = tieredWithMinimumPrice.modelType - name = tieredWithMinimumPrice.name - planPhaseOrder = tieredWithMinimumPrice.planPhaseOrder - priceType = tieredWithMinimumPrice.priceType - tieredWithMinimumConfig = tieredWithMinimumPrice.tieredWithMinimumConfig - dimensionalPriceConfiguration = tieredWithMinimumPrice.dimensionalPriceConfiguration - additionalProperties = tieredWithMinimumPrice.additionalProperties.toMutableMap() + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + id = tieredWithMinimum.id + billableMetric = tieredWithMinimum.billableMetric + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + cadence = tieredWithMinimum.cadence + conversionRate = tieredWithMinimum.conversionRate + 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 + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + dimensionalPriceConfiguration = tieredWithMinimum.dimensionalPriceConfiguration + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -45287,16 +43881,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -45402,7 +43999,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithMinimumPrice]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -45426,7 +44023,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -45435,8 +44031,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithMinimumPrice = - TieredWithMinimumPrice( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -45455,7 +44051,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -45467,7 +44063,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithMinimumPrice = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } @@ -45490,7 +44086,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -45533,7 +44133,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -47512,129 +46112,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_WITH_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -48108,7 +46585,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredWithMinimumConfig == other.tieredWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -48118,10 +46595,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredWithMinimumConfig=$tieredWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredPackageWithMinimumPrice + class TieredPackageWithMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -48141,7 +46618,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -48196,9 +46673,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -48360,10 +46835,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -48554,15 +47034,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -48626,8 +47097,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [TieredPackageWithMinimumPrice]. + * Returns a mutable builder for constructing an instance of [TieredPackageWithMinimum]. * * The following fields are required: * ```java @@ -48649,7 +47119,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -48659,7 +47128,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [TieredPackageWithMinimumPrice]. */ + /** A builder for [TieredPackageWithMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -48680,7 +47149,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + 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 @@ -48691,39 +47160,35 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackageWithMinimumPrice: TieredPackageWithMinimumPrice) = - apply { - id = tieredPackageWithMinimumPrice.id - billableMetric = tieredPackageWithMinimumPrice.billableMetric - billingCycleConfiguration = - tieredPackageWithMinimumPrice.billingCycleConfiguration - cadence = tieredPackageWithMinimumPrice.cadence - conversionRate = tieredPackageWithMinimumPrice.conversionRate - createdAt = tieredPackageWithMinimumPrice.createdAt - creditAllocation = tieredPackageWithMinimumPrice.creditAllocation - currency = tieredPackageWithMinimumPrice.currency - discount = tieredPackageWithMinimumPrice.discount - externalPriceId = tieredPackageWithMinimumPrice.externalPriceId - fixedPriceQuantity = tieredPackageWithMinimumPrice.fixedPriceQuantity - invoicingCycleConfiguration = - tieredPackageWithMinimumPrice.invoicingCycleConfiguration - item = tieredPackageWithMinimumPrice.item - maximum = tieredPackageWithMinimumPrice.maximum - maximumAmount = tieredPackageWithMinimumPrice.maximumAmount - metadata = tieredPackageWithMinimumPrice.metadata - minimum = tieredPackageWithMinimumPrice.minimum - minimumAmount = tieredPackageWithMinimumPrice.minimumAmount - modelType = tieredPackageWithMinimumPrice.modelType - name = tieredPackageWithMinimumPrice.name - planPhaseOrder = tieredPackageWithMinimumPrice.planPhaseOrder - priceType = tieredPackageWithMinimumPrice.priceType - tieredPackageWithMinimumConfig = - tieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig - dimensionalPriceConfiguration = - tieredPackageWithMinimumPrice.dimensionalPriceConfiguration - additionalProperties = - tieredPackageWithMinimumPrice.additionalProperties.toMutableMap() - } + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + id = tieredPackageWithMinimum.id + billableMetric = tieredPackageWithMinimum.billableMetric + billingCycleConfiguration = tieredPackageWithMinimum.billingCycleConfiguration + cadence = tieredPackageWithMinimum.cadence + conversionRate = tieredPackageWithMinimum.conversionRate + 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 + tieredPackageWithMinimumConfig = + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + dimensionalPriceConfiguration = + tieredPackageWithMinimum.dimensionalPriceConfiguration + additionalProperties = tieredPackageWithMinimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -49053,16 +47518,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -49169,7 +47637,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredPackageWithMinimumPrice]. + * Returns an immutable instance of [TieredPackageWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -49193,7 +47661,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -49202,8 +47669,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredPackageWithMinimumPrice = - TieredPackageWithMinimumPrice( + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -49222,7 +47689,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -49234,7 +47701,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredPackageWithMinimumPrice = apply { + fun validate(): TieredPackageWithMinimum = apply { if (validated) { return@apply } @@ -49257,7 +47724,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -49300,7 +47771,9 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -51279,129 +49752,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TIERED_PACKAGE_WITH_MINIMUM = of("tiered_package_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -51876,7 +50226,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredPackageWithMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackageWithMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -51886,10 +50236,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredPackageWithMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class PackageWithAllocationPrice + class PackageWithAllocation private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -51909,7 +50259,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageWithAllocationConfig: JsonField, private val planPhaseOrder: JsonField, @@ -51964,9 +50314,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("package_with_allocation_config") @ExcludeMissing @@ -52127,10 +50475,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -52321,15 +50674,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -52393,8 +50737,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PackageWithAllocationPrice]. + * Returns a mutable builder for constructing an instance of [PackageWithAllocation]. * * The following fields are required: * ```java @@ -52416,7 +50759,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .packageWithAllocationConfig() * .planPhaseOrder() @@ -52426,7 +50768,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PackageWithAllocationPrice]. */ + /** A builder for [PackageWithAllocation]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -52447,7 +50789,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") private var name: JsonField? = null private var packageWithAllocationConfig: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -52457,34 +50799,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(packageWithAllocationPrice: PackageWithAllocationPrice) = apply { - id = packageWithAllocationPrice.id - billableMetric = packageWithAllocationPrice.billableMetric - billingCycleConfiguration = packageWithAllocationPrice.billingCycleConfiguration - cadence = packageWithAllocationPrice.cadence - conversionRate = packageWithAllocationPrice.conversionRate - createdAt = packageWithAllocationPrice.createdAt - creditAllocation = packageWithAllocationPrice.creditAllocation - currency = packageWithAllocationPrice.currency - discount = packageWithAllocationPrice.discount - externalPriceId = packageWithAllocationPrice.externalPriceId - fixedPriceQuantity = packageWithAllocationPrice.fixedPriceQuantity - invoicingCycleConfiguration = packageWithAllocationPrice.invoicingCycleConfiguration - item = packageWithAllocationPrice.item - maximum = packageWithAllocationPrice.maximum - maximumAmount = packageWithAllocationPrice.maximumAmount - metadata = packageWithAllocationPrice.metadata - minimum = packageWithAllocationPrice.minimum - minimumAmount = packageWithAllocationPrice.minimumAmount - modelType = packageWithAllocationPrice.modelType - name = packageWithAllocationPrice.name - packageWithAllocationConfig = packageWithAllocationPrice.packageWithAllocationConfig - planPhaseOrder = packageWithAllocationPrice.planPhaseOrder - priceType = packageWithAllocationPrice.priceType - dimensionalPriceConfiguration = - packageWithAllocationPrice.dimensionalPriceConfiguration - additionalProperties = - packageWithAllocationPrice.additionalProperties.toMutableMap() + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + id = packageWithAllocation.id + billableMetric = packageWithAllocation.billableMetric + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + cadence = packageWithAllocation.cadence + conversionRate = packageWithAllocation.conversionRate + 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 + dimensionalPriceConfiguration = packageWithAllocation.dimensionalPriceConfiguration + additionalProperties = packageWithAllocation.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -52815,16 +51155,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -52931,7 +51274,7 @@ private constructor( } /** - * Returns an immutable instance of [PackageWithAllocationPrice]. + * Returns an immutable instance of [PackageWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -52955,7 +51298,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .packageWithAllocationConfig() * .planPhaseOrder() @@ -52964,8 +51306,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PackageWithAllocationPrice = - PackageWithAllocationPrice( + fun build(): PackageWithAllocation = + PackageWithAllocation( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -52984,7 +51326,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), checkRequired("planPhaseOrder", planPhaseOrder), @@ -52996,7 +51338,7 @@ private constructor( private var validated: Boolean = false - fun validate(): PackageWithAllocationPrice = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } @@ -53019,7 +51361,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageWithAllocationConfig().validate() planPhaseOrder() @@ -53062,7 +51408,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -55041,129 +53387,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * 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 { - PACKAGE_WITH_ALLOCATION, - /** - * 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) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - 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 PackageWithAllocationConfig @JsonCreator private constructor( @@ -55638,7 +53861,7 @@ private constructor( return true } - return /* spotless:off */ other is PackageWithAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -55648,10 +53871,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PackageWithAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "PackageWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class UnitWithPercentPrice + class UnitWithPercent private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -55671,7 +53894,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -55726,9 +53949,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -55889,10 +54110,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -56083,15 +54309,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -56154,7 +54371,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnitWithPercentPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. * * The following fields are required: * ```java @@ -56176,7 +54393,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -56186,7 +54402,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UnitWithPercentPrice]. */ + /** A builder for [UnitWithPercent]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -56207,7 +54423,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -56217,32 +54433,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitWithPercentPrice: UnitWithPercentPrice) = apply { - id = unitWithPercentPrice.id - billableMetric = unitWithPercentPrice.billableMetric - billingCycleConfiguration = unitWithPercentPrice.billingCycleConfiguration - cadence = unitWithPercentPrice.cadence - conversionRate = unitWithPercentPrice.conversionRate - createdAt = unitWithPercentPrice.createdAt - creditAllocation = unitWithPercentPrice.creditAllocation - currency = unitWithPercentPrice.currency - discount = unitWithPercentPrice.discount - externalPriceId = unitWithPercentPrice.externalPriceId - fixedPriceQuantity = unitWithPercentPrice.fixedPriceQuantity - invoicingCycleConfiguration = unitWithPercentPrice.invoicingCycleConfiguration - item = unitWithPercentPrice.item - maximum = unitWithPercentPrice.maximum - maximumAmount = unitWithPercentPrice.maximumAmount - metadata = unitWithPercentPrice.metadata - minimum = unitWithPercentPrice.minimum - minimumAmount = unitWithPercentPrice.minimumAmount - modelType = unitWithPercentPrice.modelType - name = unitWithPercentPrice.name - planPhaseOrder = unitWithPercentPrice.planPhaseOrder - priceType = unitWithPercentPrice.priceType - unitWithPercentConfig = unitWithPercentPrice.unitWithPercentConfig - dimensionalPriceConfiguration = unitWithPercentPrice.dimensionalPriceConfiguration - additionalProperties = unitWithPercentPrice.additionalProperties.toMutableMap() + internal fun from(unitWithPercent: UnitWithPercent) = apply { + id = unitWithPercent.id + billableMetric = unitWithPercent.billableMetric + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + cadence = unitWithPercent.cadence + conversionRate = unitWithPercent.conversionRate + 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 + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + dimensionalPriceConfiguration = unitWithPercent.dimensionalPriceConfiguration + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -56573,16 +54789,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -56689,7 +54908,7 @@ private constructor( } /** - * Returns an immutable instance of [UnitWithPercentPrice]. + * Returns an immutable instance of [UnitWithPercent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -56713,7 +54932,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -56722,8 +54940,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnitWithPercentPrice = - UnitWithPercentPrice( + fun build(): UnitWithPercent = + UnitWithPercent( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -56742,7 +54960,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -56754,7 +54972,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitWithPercentPrice = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } @@ -56777,7 +54995,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -56820,7 +55042,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -58799,129 +57021,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * 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 { - UNIT_WITH_PERCENT, - /** - * 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) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -59394,7 +57493,7 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithPercentPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercent && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && unitWithPercentConfig == other.unitWithPercentConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -59404,10 +57503,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithPercentPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithPercent{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, unitWithPercentConfig=$unitWithPercentConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class MatrixWithAllocationPrice + class MatrixWithAllocation private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -59428,7 +57527,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -59485,9 +57584,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -59652,10 +57749,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -59850,15 +57952,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -59911,8 +58004,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MatrixWithAllocationPrice]. + * Returns a mutable builder for constructing an instance of [MatrixWithAllocation]. * * The following fields are required: * ```java @@ -59935,7 +58027,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -59944,7 +58035,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixWithAllocationPrice]. */ + /** A builder for [MatrixWithAllocation]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -59966,7 +58057,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -59975,33 +58066,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixWithAllocationPrice: MatrixWithAllocationPrice) = apply { - id = matrixWithAllocationPrice.id - billableMetric = matrixWithAllocationPrice.billableMetric - billingCycleConfiguration = matrixWithAllocationPrice.billingCycleConfiguration - cadence = matrixWithAllocationPrice.cadence - conversionRate = matrixWithAllocationPrice.conversionRate - createdAt = matrixWithAllocationPrice.createdAt - creditAllocation = matrixWithAllocationPrice.creditAllocation - currency = matrixWithAllocationPrice.currency - discount = matrixWithAllocationPrice.discount - externalPriceId = matrixWithAllocationPrice.externalPriceId - fixedPriceQuantity = matrixWithAllocationPrice.fixedPriceQuantity - invoicingCycleConfiguration = matrixWithAllocationPrice.invoicingCycleConfiguration - item = matrixWithAllocationPrice.item - matrixWithAllocationConfig = matrixWithAllocationPrice.matrixWithAllocationConfig - maximum = matrixWithAllocationPrice.maximum - maximumAmount = matrixWithAllocationPrice.maximumAmount - metadata = matrixWithAllocationPrice.metadata - minimum = matrixWithAllocationPrice.minimum - minimumAmount = matrixWithAllocationPrice.minimumAmount - modelType = matrixWithAllocationPrice.modelType - name = matrixWithAllocationPrice.name - planPhaseOrder = matrixWithAllocationPrice.planPhaseOrder - priceType = matrixWithAllocationPrice.priceType - dimensionalPriceConfiguration = - matrixWithAllocationPrice.dimensionalPriceConfiguration - additionalProperties = matrixWithAllocationPrice.additionalProperties.toMutableMap() + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + id = matrixWithAllocation.id + billableMetric = matrixWithAllocation.billableMetric + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + cadence = matrixWithAllocation.cadence + conversionRate = matrixWithAllocation.conversionRate + 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 + dimensionalPriceConfiguration = matrixWithAllocation.dimensionalPriceConfiguration + additionalProperties = matrixWithAllocation.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -60346,16 +58436,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -60447,7 +58540,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithAllocationPrice]. + * Returns an immutable instance of [MatrixWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -60472,7 +58565,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -60480,8 +58572,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithAllocationPrice = - MatrixWithAllocationPrice( + fun build(): MatrixWithAllocation = + MatrixWithAllocation( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -60501,7 +58593,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -60512,7 +58604,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixWithAllocationPrice = apply { + fun validate(): MatrixWithAllocation = apply { if (validated) { return@apply } @@ -60536,7 +58628,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -60579,7 +58675,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -63130,129 +61226,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_ALLOCATION = of("matrix_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_ALLOCATION - } - - /** - * 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 { - MATRIX_WITH_ALLOCATION, - /** - * 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) { - MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -63616,7 +61589,7 @@ private constructor( return true } - return /* spotless:off */ other is MatrixWithAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -63626,10 +61599,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class TieredWithProrationPrice + class TieredWithProration private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -63649,7 +61622,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -63704,9 +61677,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -63867,10 +61838,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * 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). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -64061,15 +62037,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -64133,7 +62100,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TieredWithProrationPrice]. + * Returns a mutable builder for constructing an instance of [TieredWithProration]. * * The following fields are required: * ```java @@ -64155,7 +62122,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -64165,7 +62131,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [TieredWithProrationPrice]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -64186,7 +62152,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -64196,33 +62162,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredWithProrationPrice: TieredWithProrationPrice) = apply { - id = tieredWithProrationPrice.id - billableMetric = tieredWithProrationPrice.billableMetric - billingCycleConfiguration = tieredWithProrationPrice.billingCycleConfiguration - cadence = tieredWithProrationPrice.cadence - conversionRate = tieredWithProrationPrice.conversionRate - createdAt = tieredWithProrationPrice.createdAt - creditAllocation = tieredWithProrationPrice.creditAllocation - currency = tieredWithProrationPrice.currency - discount = tieredWithProrationPrice.discount - externalPriceId = tieredWithProrationPrice.externalPriceId - fixedPriceQuantity = tieredWithProrationPrice.fixedPriceQuantity - invoicingCycleConfiguration = tieredWithProrationPrice.invoicingCycleConfiguration - item = tieredWithProrationPrice.item - maximum = tieredWithProrationPrice.maximum - maximumAmount = tieredWithProrationPrice.maximumAmount - metadata = tieredWithProrationPrice.metadata - minimum = tieredWithProrationPrice.minimum - minimumAmount = tieredWithProrationPrice.minimumAmount - modelType = tieredWithProrationPrice.modelType - name = tieredWithProrationPrice.name - planPhaseOrder = tieredWithProrationPrice.planPhaseOrder - priceType = tieredWithProrationPrice.priceType - tieredWithProrationConfig = tieredWithProrationPrice.tieredWithProrationConfig - dimensionalPriceConfiguration = - tieredWithProrationPrice.dimensionalPriceConfiguration - additionalProperties = tieredWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(tieredWithProration: TieredWithProration) = apply { + id = tieredWithProration.id + billableMetric = tieredWithProration.billableMetric + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + cadence = tieredWithProration.cadence + conversionRate = tieredWithProration.conversionRate + 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 + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + dimensionalPriceConfiguration = tieredWithProration.dimensionalPriceConfiguration + additionalProperties = tieredWithProration.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -64553,16 +62518,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * 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: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -64668,7 +62636,7 @@ private constructor( } /** - * Returns an immutable instance of [TieredWithProrationPrice]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -64692,7 +62660,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -64701,8 +62668,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): TieredWithProrationPrice = - TieredWithProrationPrice( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -64721,7 +62688,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -64733,7 +62700,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TieredWithProrationPrice = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } @@ -64756,7 +62723,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -64799,7 +62770,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_with_proration")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (priceType.asKnown().getOrNull()?.validity() ?: 0) + @@ -66778,129 +64749,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -67374,7 +65222,7 @@ private constructor( return true } - return /* spotless:off */ other is TieredWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && tieredWithProrationConfig == other.tieredWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -67384,10 +65232,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TieredWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "TieredWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, tieredWithProrationConfig=$tieredWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class UnitWithProrationPrice + class UnitWithProration private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -67407,7 +65255,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -67462,9 +65310,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -67625,10 +65471,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -67819,15 +65670,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -67890,7 +65732,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnitWithProrationPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithProration]. * * The following fields are required: * ```java @@ -67912,7 +65754,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -67922,7 +65763,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UnitWithProrationPrice]. */ + /** A builder for [UnitWithProration]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -67943,7 +65784,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -67953,32 +65794,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unitWithProrationPrice: UnitWithProrationPrice) = apply { - id = unitWithProrationPrice.id - billableMetric = unitWithProrationPrice.billableMetric - billingCycleConfiguration = unitWithProrationPrice.billingCycleConfiguration - cadence = unitWithProrationPrice.cadence - conversionRate = unitWithProrationPrice.conversionRate - createdAt = unitWithProrationPrice.createdAt - creditAllocation = unitWithProrationPrice.creditAllocation - currency = unitWithProrationPrice.currency - discount = unitWithProrationPrice.discount - externalPriceId = unitWithProrationPrice.externalPriceId - fixedPriceQuantity = unitWithProrationPrice.fixedPriceQuantity - invoicingCycleConfiguration = unitWithProrationPrice.invoicingCycleConfiguration - item = unitWithProrationPrice.item - maximum = unitWithProrationPrice.maximum - maximumAmount = unitWithProrationPrice.maximumAmount - metadata = unitWithProrationPrice.metadata - minimum = unitWithProrationPrice.minimum - minimumAmount = unitWithProrationPrice.minimumAmount - modelType = unitWithProrationPrice.modelType - name = unitWithProrationPrice.name - planPhaseOrder = unitWithProrationPrice.planPhaseOrder - priceType = unitWithProrationPrice.priceType - unitWithProrationConfig = unitWithProrationPrice.unitWithProrationConfig - dimensionalPriceConfiguration = unitWithProrationPrice.dimensionalPriceConfiguration - additionalProperties = unitWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(unitWithProration: UnitWithProration) = apply { + id = unitWithProration.id + billableMetric = unitWithProration.billableMetric + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + cadence = unitWithProration.cadence + conversionRate = unitWithProration.conversionRate + 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 + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + dimensionalPriceConfiguration = unitWithProration.dimensionalPriceConfiguration + additionalProperties = unitWithProration.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -68309,16 +66150,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -68424,7 +66268,7 @@ private constructor( } /** - * Returns an immutable instance of [UnitWithProrationPrice]. + * Returns an immutable instance of [UnitWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -68448,7 +66292,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -68457,8 +66300,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnitWithProrationPrice = - UnitWithProrationPrice( + fun build(): UnitWithProration = + UnitWithProration( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -68477,7 +66320,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -68489,7 +66332,7 @@ private constructor( private var validated: Boolean = false - fun validate(): UnitWithProrationPrice = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } @@ -68512,7 +66355,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -68555,7 +66402,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -70534,129 +68381,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_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 { - UNIT_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) { - UNIT_WITH_PRORATION -> Value.UNIT_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) { - UNIT_WITH_PRORATION -> Known.UNIT_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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -71130,7 +68854,7 @@ private constructor( return true } - return /* spotless:off */ other is UnitWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && unitWithProrationConfig == other.unitWithProrationConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -71140,10 +68864,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UnitWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "UnitWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, unitWithProrationConfig=$unitWithProrationConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedAllocationPrice + class GroupedAllocation private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -71164,7 +68888,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -71221,9 +68945,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -71388,10 +69110,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -71585,15 +69312,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -71646,7 +69364,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [GroupedAllocationPrice]. + * Returns a mutable builder for constructing an instance of [GroupedAllocation]. * * The following fields are required: * ```java @@ -71669,7 +69387,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -71678,7 +69395,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedAllocationPrice]. */ + /** A builder for [GroupedAllocation]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -71700,7 +69417,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -71709,32 +69426,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedAllocationPrice: GroupedAllocationPrice) = apply { - id = groupedAllocationPrice.id - billableMetric = groupedAllocationPrice.billableMetric - billingCycleConfiguration = groupedAllocationPrice.billingCycleConfiguration - cadence = groupedAllocationPrice.cadence - conversionRate = groupedAllocationPrice.conversionRate - createdAt = groupedAllocationPrice.createdAt - creditAllocation = groupedAllocationPrice.creditAllocation - currency = groupedAllocationPrice.currency - discount = groupedAllocationPrice.discount - externalPriceId = groupedAllocationPrice.externalPriceId - fixedPriceQuantity = groupedAllocationPrice.fixedPriceQuantity - groupedAllocationConfig = groupedAllocationPrice.groupedAllocationConfig - invoicingCycleConfiguration = groupedAllocationPrice.invoicingCycleConfiguration - item = groupedAllocationPrice.item - maximum = groupedAllocationPrice.maximum - maximumAmount = groupedAllocationPrice.maximumAmount - metadata = groupedAllocationPrice.metadata - minimum = groupedAllocationPrice.minimum - minimumAmount = groupedAllocationPrice.minimumAmount - modelType = groupedAllocationPrice.modelType - name = groupedAllocationPrice.name - planPhaseOrder = groupedAllocationPrice.planPhaseOrder - priceType = groupedAllocationPrice.priceType - dimensionalPriceConfiguration = groupedAllocationPrice.dimensionalPriceConfiguration - additionalProperties = groupedAllocationPrice.additionalProperties.toMutableMap() + internal fun from(groupedAllocation: GroupedAllocation) = apply { + id = groupedAllocation.id + billableMetric = groupedAllocation.billableMetric + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + cadence = groupedAllocation.cadence + conversionRate = groupedAllocation.conversionRate + 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 + dimensionalPriceConfiguration = groupedAllocation.dimensionalPriceConfiguration + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -72079,16 +69796,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -72180,7 +69900,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedAllocationPrice]. + * Returns an immutable instance of [GroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -72205,7 +69925,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -72213,8 +69932,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedAllocationPrice = - GroupedAllocationPrice( + fun build(): GroupedAllocation = + GroupedAllocation( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -72234,7 +69953,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -72245,7 +69964,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedAllocationPrice = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -72269,7 +69988,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -72312,7 +70035,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -74400,129 +72123,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * 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 { - GROUPED_ALLOCATION, - /** - * 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) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -74886,7 +72486,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupedAllocationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocation && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -74896,10 +72496,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedAllocationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedAllocation{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedWithProratedMinimumPrice + class GroupedWithProratedMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -74920,7 +72520,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -74978,9 +72578,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -75145,10 +72743,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -75343,15 +72946,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -75405,7 +72999,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithProratedMinimumPrice]. + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```java @@ -75428,7 +73022,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -75437,7 +73030,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithProratedMinimumPrice]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -75461,7 +73054,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + 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 @@ -75470,39 +73063,36 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithProratedMinimumPrice: GroupedWithProratedMinimumPrice) = - apply { - id = groupedWithProratedMinimumPrice.id - billableMetric = groupedWithProratedMinimumPrice.billableMetric - billingCycleConfiguration = - groupedWithProratedMinimumPrice.billingCycleConfiguration - cadence = groupedWithProratedMinimumPrice.cadence - conversionRate = groupedWithProratedMinimumPrice.conversionRate - createdAt = groupedWithProratedMinimumPrice.createdAt - creditAllocation = groupedWithProratedMinimumPrice.creditAllocation - currency = groupedWithProratedMinimumPrice.currency - discount = groupedWithProratedMinimumPrice.discount - externalPriceId = groupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = groupedWithProratedMinimumPrice.fixedPriceQuantity - groupedWithProratedMinimumConfig = - groupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig - invoicingCycleConfiguration = - groupedWithProratedMinimumPrice.invoicingCycleConfiguration - item = groupedWithProratedMinimumPrice.item - maximum = groupedWithProratedMinimumPrice.maximum - maximumAmount = groupedWithProratedMinimumPrice.maximumAmount - metadata = groupedWithProratedMinimumPrice.metadata - minimum = groupedWithProratedMinimumPrice.minimum - minimumAmount = groupedWithProratedMinimumPrice.minimumAmount - modelType = groupedWithProratedMinimumPrice.modelType - name = groupedWithProratedMinimumPrice.name - planPhaseOrder = groupedWithProratedMinimumPrice.planPhaseOrder - priceType = groupedWithProratedMinimumPrice.priceType - dimensionalPriceConfiguration = - groupedWithProratedMinimumPrice.dimensionalPriceConfiguration - additionalProperties = - groupedWithProratedMinimumPrice.additionalProperties.toMutableMap() - } + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { + id = groupedWithProratedMinimum.id + billableMetric = groupedWithProratedMinimum.billableMetric + billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration + cadence = groupedWithProratedMinimum.cadence + conversionRate = groupedWithProratedMinimum.conversionRate + 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 + dimensionalPriceConfiguration = + groupedWithProratedMinimum.dimensionalPriceConfiguration + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -75847,16 +73437,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -75948,7 +73541,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithProratedMinimumPrice]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -75973,7 +73566,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -75981,8 +73573,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithProratedMinimumPrice = - GroupedWithProratedMinimumPrice( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -76005,7 +73597,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -76016,7 +73608,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithProratedMinimumPrice = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -76040,7 +73632,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -76083,7 +73679,9 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -78173,129 +75771,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -78659,7 +76134,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithProratedMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -78669,10 +76144,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithProratedMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedWithMeteredMinimumPrice + class GroupedWithMeteredMinimum private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -78693,7 +76168,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -78751,9 +76226,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -78918,10 +76391,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -79116,15 +76594,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -79178,7 +76647,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [GroupedWithMeteredMinimumPrice]. + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```java @@ -79201,7 +76670,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -79210,7 +76678,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedWithMeteredMinimumPrice]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -79234,7 +76702,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + 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 @@ -79243,39 +76711,35 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedWithMeteredMinimumPrice: GroupedWithMeteredMinimumPrice) = - apply { - id = groupedWithMeteredMinimumPrice.id - billableMetric = groupedWithMeteredMinimumPrice.billableMetric - billingCycleConfiguration = - groupedWithMeteredMinimumPrice.billingCycleConfiguration - cadence = groupedWithMeteredMinimumPrice.cadence - conversionRate = groupedWithMeteredMinimumPrice.conversionRate - createdAt = groupedWithMeteredMinimumPrice.createdAt - creditAllocation = groupedWithMeteredMinimumPrice.creditAllocation - currency = groupedWithMeteredMinimumPrice.currency - discount = groupedWithMeteredMinimumPrice.discount - externalPriceId = groupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = groupedWithMeteredMinimumPrice.fixedPriceQuantity - groupedWithMeteredMinimumConfig = - groupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig - invoicingCycleConfiguration = - groupedWithMeteredMinimumPrice.invoicingCycleConfiguration - item = groupedWithMeteredMinimumPrice.item - maximum = groupedWithMeteredMinimumPrice.maximum - maximumAmount = groupedWithMeteredMinimumPrice.maximumAmount - metadata = groupedWithMeteredMinimumPrice.metadata - minimum = groupedWithMeteredMinimumPrice.minimum - minimumAmount = groupedWithMeteredMinimumPrice.minimumAmount - modelType = groupedWithMeteredMinimumPrice.modelType - name = groupedWithMeteredMinimumPrice.name - planPhaseOrder = groupedWithMeteredMinimumPrice.planPhaseOrder - priceType = groupedWithMeteredMinimumPrice.priceType - dimensionalPriceConfiguration = - groupedWithMeteredMinimumPrice.dimensionalPriceConfiguration - additionalProperties = - groupedWithMeteredMinimumPrice.additionalProperties.toMutableMap() - } + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { + id = groupedWithMeteredMinimum.id + billableMetric = groupedWithMeteredMinimum.billableMetric + billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration + cadence = groupedWithMeteredMinimum.cadence + conversionRate = groupedWithMeteredMinimum.conversionRate + 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 + dimensionalPriceConfiguration = + groupedWithMeteredMinimum.dimensionalPriceConfiguration + additionalProperties = groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -79620,16 +77084,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -79721,7 +77188,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedWithMeteredMinimumPrice]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -79746,7 +77213,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -79754,8 +77220,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedWithMeteredMinimumPrice = - GroupedWithMeteredMinimumPrice( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -79778,7 +77244,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -79789,7 +77255,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedWithMeteredMinimumPrice = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -79813,7 +77279,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -79856,7 +77326,9 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -81946,129 +79418,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -82432,7 +79781,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupedWithMeteredMinimumPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimum && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -82442,10 +79791,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedWithMeteredMinimumPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class MatrixWithDisplayNamePrice + class MatrixWithDisplayName private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -82466,7 +79815,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -82523,9 +79872,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -82690,10 +80037,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -82888,15 +80240,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -82949,8 +80292,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MatrixWithDisplayNamePrice]. + * Returns a mutable builder for constructing an instance of [MatrixWithDisplayName]. * * The following fields are required: * ```java @@ -82973,7 +80315,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -82982,7 +80323,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MatrixWithDisplayNamePrice]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -83004,7 +80345,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + 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 @@ -83013,34 +80354,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(matrixWithDisplayNamePrice: MatrixWithDisplayNamePrice) = apply { - id = matrixWithDisplayNamePrice.id - billableMetric = matrixWithDisplayNamePrice.billableMetric - billingCycleConfiguration = matrixWithDisplayNamePrice.billingCycleConfiguration - cadence = matrixWithDisplayNamePrice.cadence - conversionRate = matrixWithDisplayNamePrice.conversionRate - createdAt = matrixWithDisplayNamePrice.createdAt - creditAllocation = matrixWithDisplayNamePrice.creditAllocation - currency = matrixWithDisplayNamePrice.currency - discount = matrixWithDisplayNamePrice.discount - externalPriceId = matrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = matrixWithDisplayNamePrice.fixedPriceQuantity - invoicingCycleConfiguration = matrixWithDisplayNamePrice.invoicingCycleConfiguration - item = matrixWithDisplayNamePrice.item - matrixWithDisplayNameConfig = matrixWithDisplayNamePrice.matrixWithDisplayNameConfig - maximum = matrixWithDisplayNamePrice.maximum - maximumAmount = matrixWithDisplayNamePrice.maximumAmount - metadata = matrixWithDisplayNamePrice.metadata - minimum = matrixWithDisplayNamePrice.minimum - minimumAmount = matrixWithDisplayNamePrice.minimumAmount - modelType = matrixWithDisplayNamePrice.modelType - name = matrixWithDisplayNamePrice.name - planPhaseOrder = matrixWithDisplayNamePrice.planPhaseOrder - priceType = matrixWithDisplayNamePrice.priceType - dimensionalPriceConfiguration = - matrixWithDisplayNamePrice.dimensionalPriceConfiguration - additionalProperties = - matrixWithDisplayNamePrice.additionalProperties.toMutableMap() + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + id = matrixWithDisplayName.id + billableMetric = matrixWithDisplayName.billableMetric + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + cadence = matrixWithDisplayName.cadence + conversionRate = matrixWithDisplayName.conversionRate + 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 + dimensionalPriceConfiguration = matrixWithDisplayName.dimensionalPriceConfiguration + additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -83386,16 +80725,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -83487,7 +80829,7 @@ private constructor( } /** - * Returns an immutable instance of [MatrixWithDisplayNamePrice]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -83512,7 +80854,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -83520,8 +80861,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MatrixWithDisplayNamePrice = - MatrixWithDisplayNamePrice( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -83541,7 +80882,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -83552,7 +80893,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MatrixWithDisplayNamePrice = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -83576,7 +80917,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -83619,7 +80964,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -85708,129 +83053,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * 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 { - MATRIX_WITH_DISPLAY_NAME, - /** - * 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) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -86194,7 +83416,7 @@ private constructor( return true } - return /* spotless:off */ other is MatrixWithDisplayNamePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayName && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -86204,10 +83426,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MatrixWithDisplayNamePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class BulkWithProrationPrice + class BulkWithProration private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -86228,7 +83450,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -86285,9 +83507,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -86452,10 +83672,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -86649,15 +83874,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -86710,7 +83926,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [BulkWithProrationPrice]. + * Returns a mutable builder for constructing an instance of [BulkWithProration]. * * The following fields are required: * ```java @@ -86733,7 +83949,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -86742,7 +83957,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BulkWithProrationPrice]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -86764,7 +83979,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -86773,32 +83988,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(bulkWithProrationPrice: BulkWithProrationPrice) = apply { - id = bulkWithProrationPrice.id - billableMetric = bulkWithProrationPrice.billableMetric - billingCycleConfiguration = bulkWithProrationPrice.billingCycleConfiguration - bulkWithProrationConfig = bulkWithProrationPrice.bulkWithProrationConfig - cadence = bulkWithProrationPrice.cadence - conversionRate = bulkWithProrationPrice.conversionRate - createdAt = bulkWithProrationPrice.createdAt - creditAllocation = bulkWithProrationPrice.creditAllocation - currency = bulkWithProrationPrice.currency - discount = bulkWithProrationPrice.discount - externalPriceId = bulkWithProrationPrice.externalPriceId - fixedPriceQuantity = bulkWithProrationPrice.fixedPriceQuantity - invoicingCycleConfiguration = bulkWithProrationPrice.invoicingCycleConfiguration - item = bulkWithProrationPrice.item - maximum = bulkWithProrationPrice.maximum - maximumAmount = bulkWithProrationPrice.maximumAmount - metadata = bulkWithProrationPrice.metadata - minimum = bulkWithProrationPrice.minimum - minimumAmount = bulkWithProrationPrice.minimumAmount - modelType = bulkWithProrationPrice.modelType - name = bulkWithProrationPrice.name - planPhaseOrder = bulkWithProrationPrice.planPhaseOrder - priceType = bulkWithProrationPrice.priceType - dimensionalPriceConfiguration = bulkWithProrationPrice.dimensionalPriceConfiguration - additionalProperties = bulkWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(bulkWithProration: BulkWithProration) = apply { + id = bulkWithProration.id + billableMetric = bulkWithProration.billableMetric + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + conversionRate = bulkWithProration.conversionRate + 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 + dimensionalPriceConfiguration = bulkWithProration.dimensionalPriceConfiguration + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -87143,16 +84358,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -87244,7 +84462,7 @@ private constructor( } /** - * Returns an immutable instance of [BulkWithProrationPrice]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -87269,7 +84487,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -87277,8 +84494,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BulkWithProrationPrice = - BulkWithProrationPrice( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -87298,7 +84515,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -87309,7 +84526,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BulkWithProrationPrice = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -87333,7 +84550,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -87376,7 +84597,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -89464,129 +86685,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_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 { - BULK_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) { - BULK_WITH_PRORATION -> Value.BULK_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) { - BULK_WITH_PRORATION -> Known.BULK_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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -89950,7 +87048,7 @@ private constructor( return true } - return /* spotless:off */ other is BulkWithProrationPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkWithProration && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && bulkWithProrationConfig == other.bulkWithProrationConfig && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -89960,10 +87058,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BulkWithProrationPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "BulkWithProration{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class GroupedTieredPackagePrice + class GroupedTieredPackage private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -89984,7 +87082,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -90041,9 +87139,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -90208,10 +87304,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -90406,15 +87507,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -90467,8 +87559,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [GroupedTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. * * The following fields are required: * ```java @@ -90491,7 +87582,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -90500,7 +87590,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [GroupedTieredPackagePrice]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -90522,7 +87612,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -90531,33 +87621,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(groupedTieredPackagePrice: GroupedTieredPackagePrice) = apply { - id = groupedTieredPackagePrice.id - billableMetric = groupedTieredPackagePrice.billableMetric - billingCycleConfiguration = groupedTieredPackagePrice.billingCycleConfiguration - cadence = groupedTieredPackagePrice.cadence - conversionRate = groupedTieredPackagePrice.conversionRate - createdAt = groupedTieredPackagePrice.createdAt - creditAllocation = groupedTieredPackagePrice.creditAllocation - currency = groupedTieredPackagePrice.currency - discount = groupedTieredPackagePrice.discount - externalPriceId = groupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = groupedTieredPackagePrice.fixedPriceQuantity - groupedTieredPackageConfig = groupedTieredPackagePrice.groupedTieredPackageConfig - invoicingCycleConfiguration = groupedTieredPackagePrice.invoicingCycleConfiguration - item = groupedTieredPackagePrice.item - maximum = groupedTieredPackagePrice.maximum - maximumAmount = groupedTieredPackagePrice.maximumAmount - metadata = groupedTieredPackagePrice.metadata - minimum = groupedTieredPackagePrice.minimum - minimumAmount = groupedTieredPackagePrice.minimumAmount - modelType = groupedTieredPackagePrice.modelType - name = groupedTieredPackagePrice.name - planPhaseOrder = groupedTieredPackagePrice.planPhaseOrder - priceType = groupedTieredPackagePrice.priceType - dimensionalPriceConfiguration = - groupedTieredPackagePrice.dimensionalPriceConfiguration - additionalProperties = groupedTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + id = groupedTieredPackage.id + billableMetric = groupedTieredPackage.billableMetric + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + cadence = groupedTieredPackage.cadence + conversionRate = groupedTieredPackage.conversionRate + 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 + dimensionalPriceConfiguration = groupedTieredPackage.dimensionalPriceConfiguration + additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -90902,16 +87991,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -91003,7 +88095,7 @@ private constructor( } /** - * Returns an immutable instance of [GroupedTieredPackagePrice]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -91028,7 +88120,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -91036,8 +88127,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): GroupedTieredPackagePrice = - GroupedTieredPackagePrice( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -91057,7 +88148,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -91068,7 +88159,7 @@ private constructor( private var validated: Boolean = false - fun validate(): GroupedTieredPackagePrice = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -91092,7 +88183,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -91135,7 +88230,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -93223,129 +90318,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * 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 { - GROUPED_TIERED_PACKAGE, - /** - * 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) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -93709,7 +90681,7 @@ private constructor( return true } - return /* spotless:off */ other is GroupedTieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -93719,10 +90691,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "GroupedTieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class MaxGroupTieredPackagePrice + class MaxGroupTieredPackage private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -93743,7 +90715,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -93800,9 +90772,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -93967,10 +90937,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -94165,15 +91140,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -94226,8 +91192,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [MaxGroupTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [MaxGroupTieredPackage]. * * The following fields are required: * ```java @@ -94250,7 +91215,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -94259,7 +91223,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MaxGroupTieredPackagePrice]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -94281,7 +91245,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + 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 @@ -94290,34 +91254,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(maxGroupTieredPackagePrice: MaxGroupTieredPackagePrice) = apply { - id = maxGroupTieredPackagePrice.id - billableMetric = maxGroupTieredPackagePrice.billableMetric - billingCycleConfiguration = maxGroupTieredPackagePrice.billingCycleConfiguration - cadence = maxGroupTieredPackagePrice.cadence - conversionRate = maxGroupTieredPackagePrice.conversionRate - createdAt = maxGroupTieredPackagePrice.createdAt - creditAllocation = maxGroupTieredPackagePrice.creditAllocation - currency = maxGroupTieredPackagePrice.currency - discount = maxGroupTieredPackagePrice.discount - externalPriceId = maxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = maxGroupTieredPackagePrice.fixedPriceQuantity - invoicingCycleConfiguration = maxGroupTieredPackagePrice.invoicingCycleConfiguration - item = maxGroupTieredPackagePrice.item - maxGroupTieredPackageConfig = maxGroupTieredPackagePrice.maxGroupTieredPackageConfig - maximum = maxGroupTieredPackagePrice.maximum - maximumAmount = maxGroupTieredPackagePrice.maximumAmount - metadata = maxGroupTieredPackagePrice.metadata - minimum = maxGroupTieredPackagePrice.minimum - minimumAmount = maxGroupTieredPackagePrice.minimumAmount - modelType = maxGroupTieredPackagePrice.modelType - name = maxGroupTieredPackagePrice.name - planPhaseOrder = maxGroupTieredPackagePrice.planPhaseOrder - priceType = maxGroupTieredPackagePrice.priceType - dimensionalPriceConfiguration = - maxGroupTieredPackagePrice.dimensionalPriceConfiguration - additionalProperties = - maxGroupTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + id = maxGroupTieredPackage.id + billableMetric = maxGroupTieredPackage.billableMetric + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + cadence = maxGroupTieredPackage.cadence + conversionRate = maxGroupTieredPackage.conversionRate + 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 + dimensionalPriceConfiguration = maxGroupTieredPackage.dimensionalPriceConfiguration + additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -94663,16 +91625,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -94764,7 +91729,7 @@ private constructor( } /** - * Returns an immutable instance of [MaxGroupTieredPackagePrice]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -94789,7 +91754,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -94797,8 +91761,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MaxGroupTieredPackagePrice = - MaxGroupTieredPackagePrice( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -94818,7 +91782,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -94829,7 +91793,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MaxGroupTieredPackagePrice = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -94853,7 +91817,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -94896,7 +91864,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -96985,129 +93953,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * 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 { - MAX_GROUP_TIERED_PACKAGE, - /** - * 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) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -97471,7 +94316,7 @@ private constructor( return true } - return /* spotless:off */ other is MaxGroupTieredPackagePrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MaxGroupTieredPackage && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -97481,10 +94326,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MaxGroupTieredPackagePrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class ScalableMatrixWithUnitPricingPrice + class ScalableMatrixWithUnitPricing private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -97504,7 +94349,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -97560,9 +94405,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -97724,10 +94567,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -97920,15 +94768,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -97993,7 +94832,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithUnitPricingPrice]. + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java @@ -98015,7 +94854,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -98025,7 +94863,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -98046,7 +94884,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + 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 @@ -98058,40 +94896,39 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - scalableMatrixWithUnitPricingPrice: ScalableMatrixWithUnitPricingPrice - ) = apply { - id = scalableMatrixWithUnitPricingPrice.id - billableMetric = scalableMatrixWithUnitPricingPrice.billableMetric - billingCycleConfiguration = - scalableMatrixWithUnitPricingPrice.billingCycleConfiguration - cadence = scalableMatrixWithUnitPricingPrice.cadence - conversionRate = scalableMatrixWithUnitPricingPrice.conversionRate - createdAt = scalableMatrixWithUnitPricingPrice.createdAt - creditAllocation = scalableMatrixWithUnitPricingPrice.creditAllocation - currency = scalableMatrixWithUnitPricingPrice.currency - discount = scalableMatrixWithUnitPricingPrice.discount - externalPriceId = scalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = scalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoicingCycleConfiguration = - scalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration - item = scalableMatrixWithUnitPricingPrice.item - maximum = scalableMatrixWithUnitPricingPrice.maximum - maximumAmount = scalableMatrixWithUnitPricingPrice.maximumAmount - metadata = scalableMatrixWithUnitPricingPrice.metadata - minimum = scalableMatrixWithUnitPricingPrice.minimum - minimumAmount = scalableMatrixWithUnitPricingPrice.minimumAmount - modelType = scalableMatrixWithUnitPricingPrice.modelType - name = scalableMatrixWithUnitPricingPrice.name - planPhaseOrder = scalableMatrixWithUnitPricingPrice.planPhaseOrder - priceType = scalableMatrixWithUnitPricingPrice.priceType - scalableMatrixWithUnitPricingConfig = - scalableMatrixWithUnitPricingPrice.scalableMatrixWithUnitPricingConfig - dimensionalPriceConfiguration = - scalableMatrixWithUnitPricingPrice.dimensionalPriceConfiguration - additionalProperties = - scalableMatrixWithUnitPricingPrice.additionalProperties.toMutableMap() - } + internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = + apply { + id = scalableMatrixWithUnitPricing.id + billableMetric = scalableMatrixWithUnitPricing.billableMetric + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + cadence = scalableMatrixWithUnitPricing.cadence + conversionRate = scalableMatrixWithUnitPricing.conversionRate + 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 + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithUnitPricing.dimensionalPriceConfiguration + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -98421,16 +95258,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -98542,7 +95382,7 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithUnitPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -98566,7 +95406,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -98575,8 +95414,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithUnitPricingPrice = - ScalableMatrixWithUnitPricingPrice( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -98595,7 +95434,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -98610,7 +95449,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ScalableMatrixWithUnitPricingPrice = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } @@ -98633,7 +95472,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -98676,7 +95519,9 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -100655,130 +97500,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField - val SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -101254,7 +97975,7 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithUnitPricingPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithUnitPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && scalableMatrixWithUnitPricingConfig == other.scalableMatrixWithUnitPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -101264,10 +97985,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithUnitPricingPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class ScalableMatrixWithTieredPricingPrice + class ScalableMatrixWithTieredPricing private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -101287,7 +98008,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -101343,9 +98064,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -101508,10 +98227,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -101704,15 +98428,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -101777,7 +98492,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [ScalableMatrixWithTieredPricingPrice]. + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java @@ -101799,7 +98514,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -101809,7 +98523,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [ScalableMatrixWithTieredPricingPrice]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -101830,7 +98544,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -101842,40 +98556,39 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - scalableMatrixWithTieredPricingPrice: ScalableMatrixWithTieredPricingPrice - ) = apply { - id = scalableMatrixWithTieredPricingPrice.id - billableMetric = scalableMatrixWithTieredPricingPrice.billableMetric - billingCycleConfiguration = - scalableMatrixWithTieredPricingPrice.billingCycleConfiguration - cadence = scalableMatrixWithTieredPricingPrice.cadence - conversionRate = scalableMatrixWithTieredPricingPrice.conversionRate - createdAt = scalableMatrixWithTieredPricingPrice.createdAt - creditAllocation = scalableMatrixWithTieredPricingPrice.creditAllocation - currency = scalableMatrixWithTieredPricingPrice.currency - discount = scalableMatrixWithTieredPricingPrice.discount - externalPriceId = scalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = scalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoicingCycleConfiguration = - scalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration - item = scalableMatrixWithTieredPricingPrice.item - maximum = scalableMatrixWithTieredPricingPrice.maximum - maximumAmount = scalableMatrixWithTieredPricingPrice.maximumAmount - metadata = scalableMatrixWithTieredPricingPrice.metadata - minimum = scalableMatrixWithTieredPricingPrice.minimum - minimumAmount = scalableMatrixWithTieredPricingPrice.minimumAmount - modelType = scalableMatrixWithTieredPricingPrice.modelType - name = scalableMatrixWithTieredPricingPrice.name - planPhaseOrder = scalableMatrixWithTieredPricingPrice.planPhaseOrder - priceType = scalableMatrixWithTieredPricingPrice.priceType - scalableMatrixWithTieredPricingConfig = - scalableMatrixWithTieredPricingPrice.scalableMatrixWithTieredPricingConfig - dimensionalPriceConfiguration = - scalableMatrixWithTieredPricingPrice.dimensionalPriceConfiguration - additionalProperties = - scalableMatrixWithTieredPricingPrice.additionalProperties.toMutableMap() - } + internal fun from(scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing) = + apply { + id = scalableMatrixWithTieredPricing.id + billableMetric = scalableMatrixWithTieredPricing.billableMetric + billingCycleConfiguration = + scalableMatrixWithTieredPricing.billingCycleConfiguration + cadence = scalableMatrixWithTieredPricing.cadence + conversionRate = scalableMatrixWithTieredPricing.conversionRate + 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 + scalableMatrixWithTieredPricingConfig = + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + dimensionalPriceConfiguration = + scalableMatrixWithTieredPricing.dimensionalPriceConfiguration + additionalProperties = + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -102205,16 +98918,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -102327,7 +99043,7 @@ private constructor( } /** - * Returns an immutable instance of [ScalableMatrixWithTieredPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -102351,7 +99067,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -102360,8 +99075,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): ScalableMatrixWithTieredPricingPrice = - ScalableMatrixWithTieredPricingPrice( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -102380,7 +99095,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -102395,7 +99110,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ScalableMatrixWithTieredPricingPrice = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } @@ -102418,7 +99133,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -102461,7 +99180,9 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -104440,130 +101161,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField - val SCALABLE_MATRIX_WITH_TIERED_PRICING = of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -105039,7 +101636,7 @@ private constructor( return true } - return /* spotless:off */ other is ScalableMatrixWithTieredPricingPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithTieredPricing && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && scalableMatrixWithTieredPricingConfig == other.scalableMatrixWithTieredPricingConfig && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -105049,10 +101646,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ScalableMatrixWithTieredPricingPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" } - class CumulativeGroupedBulkPrice + class CumulativeGroupedBulk private constructor( private val id: JsonField, private val billableMetric: JsonField, @@ -105073,7 +101670,7 @@ private constructor( private val metadata: JsonField, private val minimum: JsonField, private val minimumAmount: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val planPhaseOrder: JsonField, private val priceType: JsonField, @@ -105130,9 +101727,7 @@ private constructor( @JsonProperty("minimum_amount") @ExcludeMissing minimumAmount: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("plan_phase_order") @ExcludeMissing @@ -105297,10 +101892,15 @@ private constructor( fun minimumAmount(): Optional = minimumAmount.getOptional("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). + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -105495,15 +102095,6 @@ private constructor( @ExcludeMissing fun _minimumAmount(): JsonField = minimumAmount - /** - * 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]. * @@ -105556,8 +102147,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [CumulativeGroupedBulkPrice]. + * Returns a mutable builder for constructing an instance of [CumulativeGroupedBulk]. * * The following fields are required: * ```java @@ -105580,7 +102170,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -105589,7 +102178,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [CumulativeGroupedBulkPrice]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -105611,7 +102200,7 @@ private constructor( private var metadata: JsonField? = null private var minimum: JsonField? = null private var minimumAmount: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var planPhaseOrder: JsonField? = null private var priceType: JsonField? = null @@ -105620,34 +102209,32 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(cumulativeGroupedBulkPrice: CumulativeGroupedBulkPrice) = apply { - id = cumulativeGroupedBulkPrice.id - billableMetric = cumulativeGroupedBulkPrice.billableMetric - billingCycleConfiguration = cumulativeGroupedBulkPrice.billingCycleConfiguration - cadence = cumulativeGroupedBulkPrice.cadence - conversionRate = cumulativeGroupedBulkPrice.conversionRate - createdAt = cumulativeGroupedBulkPrice.createdAt - creditAllocation = cumulativeGroupedBulkPrice.creditAllocation - cumulativeGroupedBulkConfig = cumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - currency = cumulativeGroupedBulkPrice.currency - discount = cumulativeGroupedBulkPrice.discount - externalPriceId = cumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = cumulativeGroupedBulkPrice.fixedPriceQuantity - invoicingCycleConfiguration = cumulativeGroupedBulkPrice.invoicingCycleConfiguration - item = cumulativeGroupedBulkPrice.item - maximum = cumulativeGroupedBulkPrice.maximum - maximumAmount = cumulativeGroupedBulkPrice.maximumAmount - metadata = cumulativeGroupedBulkPrice.metadata - minimum = cumulativeGroupedBulkPrice.minimum - minimumAmount = cumulativeGroupedBulkPrice.minimumAmount - modelType = cumulativeGroupedBulkPrice.modelType - name = cumulativeGroupedBulkPrice.name - planPhaseOrder = cumulativeGroupedBulkPrice.planPhaseOrder - priceType = cumulativeGroupedBulkPrice.priceType - dimensionalPriceConfiguration = - cumulativeGroupedBulkPrice.dimensionalPriceConfiguration - additionalProperties = - cumulativeGroupedBulkPrice.additionalProperties.toMutableMap() + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + id = cumulativeGroupedBulk.id + billableMetric = cumulativeGroupedBulk.billableMetric + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + cadence = cumulativeGroupedBulk.cadence + conversionRate = cumulativeGroupedBulk.conversionRate + 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 + dimensionalPriceConfiguration = cumulativeGroupedBulk.dimensionalPriceConfiguration + additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -105993,16 +102580,19 @@ private constructor( this.minimumAmount = minimumAmount } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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 + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } fun name(name: String) = name(JsonField.of(name)) @@ -106094,7 +102684,7 @@ private constructor( } /** - * Returns an immutable instance of [CumulativeGroupedBulkPrice]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -106119,7 +102709,6 @@ private constructor( * .metadata() * .minimum() * .minimumAmount() - * .modelType() * .name() * .planPhaseOrder() * .priceType() @@ -106127,8 +102716,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): CumulativeGroupedBulkPrice = - CumulativeGroupedBulkPrice( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("id", id), checkRequired("billableMetric", billableMetric), checkRequired("billingCycleConfiguration", billingCycleConfiguration), @@ -106148,7 +102737,7 @@ private constructor( checkRequired("metadata", metadata), checkRequired("minimum", minimum), checkRequired("minimumAmount", minimumAmount), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("planPhaseOrder", planPhaseOrder), checkRequired("priceType", priceType), @@ -106159,7 +102748,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CumulativeGroupedBulkPrice = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -106183,7 +102772,11 @@ private constructor( metadata().validate() minimum().ifPresent { it.validate() } minimumAmount() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() planPhaseOrder() priceType().validate() @@ -106226,7 +102819,7 @@ private constructor( (metadata.asKnown().getOrNull()?.validity() ?: 0) + (minimum.asKnown().getOrNull()?.validity() ?: 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -108315,129 +104908,6 @@ private constructor( "Minimum{appliesToPriceIds=$appliesToPriceIds, minimumAmount=$minimumAmount, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * 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 { - CUMULATIVE_GROUPED_BULK, - /** - * 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) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - 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 PriceType @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -108801,7 +105271,7 @@ private constructor( return true } - return /* spotless:off */ other is CumulativeGroupedBulkPrice && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CumulativeGroupedBulk && id == other.id && billableMetric == other.billableMetric && billingCycleConfiguration == other.billingCycleConfiguration && cadence == other.cadence && conversionRate == other.conversionRate && 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 && dimensionalPriceConfiguration == other.dimensionalPriceConfiguration && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -108811,6 +105281,6 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CumulativeGroupedBulkPrice{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, dimensionalPriceConfiguration=$dimensionalPriceConfiguration, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{id=$id, billableMetric=$billableMetric, billingCycleConfiguration=$billingCycleConfiguration, cadence=$cadence, conversionRate=$conversionRate, 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, 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 e9b9c86e..6a0cf972 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 @@ -31,6 +31,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.Unit as KUnit import kotlin.jvm.optionals.getOrNull /** @@ -89,238 +90,122 @@ private constructor( fun body(body: Body) = apply { this.body = body } - /** Alias for calling [body] with `Body.ofNewFloatingUnitPrice(newFloatingUnitPrice)`. */ - fun body(newFloatingUnitPrice: Body.NewFloatingUnitPrice) = - body(Body.ofNewFloatingUnitPrice(newFloatingUnitPrice)) + /** Alias for calling [body] with `Body.ofUnit(unit)`. */ + fun body(unit: Body.Unit) = body(Body.ofUnit(unit)) - /** - * Alias for calling [body] with `Body.ofNewFloatingPackagePrice(newFloatingPackagePrice)`. - */ - fun body(newFloatingPackagePrice: Body.NewFloatingPackagePrice) = - body(Body.ofNewFloatingPackagePrice(newFloatingPackagePrice)) + /** Alias for calling [body] with `Body.ofPackage(package_)`. */ + fun body(package_: Body.Package) = body(Body.ofPackage(package_)) - /** - * Alias for calling [body] with `Body.ofNewFloatingMatrixPrice(newFloatingMatrixPrice)`. - */ - fun body(newFloatingMatrixPrice: Body.NewFloatingMatrixPrice) = - body(Body.ofNewFloatingMatrixPrice(newFloatingMatrixPrice)) + /** Alias for calling [body] with `Body.ofMatrix(matrix)`. */ + fun body(matrix: Body.Matrix) = body(Body.ofMatrix(matrix)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingMatrixWithAllocationPrice(newFloatingMatrixWithAllocationPrice)`. - */ - fun body(newFloatingMatrixWithAllocationPrice: Body.NewFloatingMatrixWithAllocationPrice) = - body(Body.ofNewFloatingMatrixWithAllocationPrice(newFloatingMatrixWithAllocationPrice)) + /** Alias for calling [body] with `Body.ofMatrixWithAllocation(matrixWithAllocation)`. */ + fun body(matrixWithAllocation: Body.MatrixWithAllocation) = + body(Body.ofMatrixWithAllocation(matrixWithAllocation)) - /** - * Alias for calling [body] with `Body.ofNewFloatingTieredPrice(newFloatingTieredPrice)`. - */ - fun body(newFloatingTieredPrice: Body.NewFloatingTieredPrice) = - body(Body.ofNewFloatingTieredPrice(newFloatingTieredPrice)) + /** Alias for calling [body] with `Body.ofTiered(tiered)`. */ + fun body(tiered: Body.Tiered) = body(Body.ofTiered(tiered)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingTieredBpsPrice(newFloatingTieredBpsPrice)`. - */ - fun body(newFloatingTieredBpsPrice: Body.NewFloatingTieredBpsPrice) = - body(Body.ofNewFloatingTieredBpsPrice(newFloatingTieredBpsPrice)) + /** Alias for calling [body] with `Body.ofTieredBps(tieredBps)`. */ + fun body(tieredBps: Body.TieredBps) = body(Body.ofTieredBps(tieredBps)) - /** Alias for calling [body] with `Body.ofNewFloatingBpsPrice(newFloatingBpsPrice)`. */ - fun body(newFloatingBpsPrice: Body.NewFloatingBpsPrice) = - body(Body.ofNewFloatingBpsPrice(newFloatingBpsPrice)) + /** Alias for calling [body] with `Body.ofBps(bps)`. */ + fun body(bps: Body.Bps) = body(Body.ofBps(bps)) - /** - * Alias for calling [body] with `Body.ofNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice)`. - */ - fun body(newFloatingBulkBpsPrice: Body.NewFloatingBulkBpsPrice) = - body(Body.ofNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice)) + /** Alias for calling [body] with `Body.ofBulkBps(bulkBps)`. */ + fun body(bulkBps: Body.BulkBps) = body(Body.ofBulkBps(bulkBps)) - /** Alias for calling [body] with `Body.ofNewFloatingBulkPrice(newFloatingBulkPrice)`. */ - fun body(newFloatingBulkPrice: Body.NewFloatingBulkPrice) = - body(Body.ofNewFloatingBulkPrice(newFloatingBulkPrice)) + /** Alias for calling [body] with `Body.ofBulk(bulk)`. */ + fun body(bulk: Body.Bulk) = body(Body.ofBulk(bulk)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingThresholdTotalAmountPrice(newFloatingThresholdTotalAmountPrice)`. - */ - fun body(newFloatingThresholdTotalAmountPrice: Body.NewFloatingThresholdTotalAmountPrice) = - body(Body.ofNewFloatingThresholdTotalAmountPrice(newFloatingThresholdTotalAmountPrice)) + /** Alias for calling [body] with `Body.ofThresholdTotalAmount(thresholdTotalAmount)`. */ + fun body(thresholdTotalAmount: Body.ThresholdTotalAmount) = + body(Body.ofThresholdTotalAmount(thresholdTotalAmount)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingTieredPackagePrice(newFloatingTieredPackagePrice)`. - */ - fun body(newFloatingTieredPackagePrice: Body.NewFloatingTieredPackagePrice) = - body(Body.ofNewFloatingTieredPackagePrice(newFloatingTieredPackagePrice)) + /** Alias for calling [body] with `Body.ofTieredPackage(tieredPackage)`. */ + fun body(tieredPackage: Body.TieredPackage) = body(Body.ofTieredPackage(tieredPackage)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingGroupedTieredPrice(newFloatingGroupedTieredPrice)`. - */ - fun body(newFloatingGroupedTieredPrice: Body.NewFloatingGroupedTieredPrice) = - body(Body.ofNewFloatingGroupedTieredPrice(newFloatingGroupedTieredPrice)) + /** Alias for calling [body] with `Body.ofGroupedTiered(groupedTiered)`. */ + fun body(groupedTiered: Body.GroupedTiered) = body(Body.ofGroupedTiered(groupedTiered)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingMaxGroupTieredPackagePrice(newFloatingMaxGroupTieredPackagePrice)`. - */ - fun body( - newFloatingMaxGroupTieredPackagePrice: Body.NewFloatingMaxGroupTieredPackagePrice - ) = - body( - Body.ofNewFloatingMaxGroupTieredPackagePrice(newFloatingMaxGroupTieredPackagePrice) - ) + /** Alias for calling [body] with `Body.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ + fun body(maxGroupTieredPackage: Body.MaxGroupTieredPackage) = + body(Body.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingTieredWithMinimumPrice(newFloatingTieredWithMinimumPrice)`. - */ - fun body(newFloatingTieredWithMinimumPrice: Body.NewFloatingTieredWithMinimumPrice) = - body(Body.ofNewFloatingTieredWithMinimumPrice(newFloatingTieredWithMinimumPrice)) + /** Alias for calling [body] with `Body.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun body(tieredWithMinimum: Body.TieredWithMinimum) = + body(Body.ofTieredWithMinimum(tieredWithMinimum)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingPackageWithAllocationPrice(newFloatingPackageWithAllocationPrice)`. - */ - fun body( - newFloatingPackageWithAllocationPrice: Body.NewFloatingPackageWithAllocationPrice - ) = - body( - Body.ofNewFloatingPackageWithAllocationPrice(newFloatingPackageWithAllocationPrice) - ) + /** Alias for calling [body] with `Body.ofPackageWithAllocation(packageWithAllocation)`. */ + fun body(packageWithAllocation: Body.PackageWithAllocation) = + body(Body.ofPackageWithAllocation(packageWithAllocation)) /** * Alias for calling [body] with - * `Body.ofNewFloatingTieredPackageWithMinimumPrice(newFloatingTieredPackageWithMinimumPrice)`. + * `Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun body( - newFloatingTieredPackageWithMinimumPrice: Body.NewFloatingTieredPackageWithMinimumPrice - ) = - body( - Body.ofNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice - ) - ) + fun body(tieredPackageWithMinimum: Body.TieredPackageWithMinimum) = + body(Body.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingUnitWithPercentPrice(newFloatingUnitWithPercentPrice)`. - */ - fun body(newFloatingUnitWithPercentPrice: Body.NewFloatingUnitWithPercentPrice) = - body(Body.ofNewFloatingUnitWithPercentPrice(newFloatingUnitWithPercentPrice)) + /** Alias for calling [body] with `Body.ofUnitWithPercent(unitWithPercent)`. */ + fun body(unitWithPercent: Body.UnitWithPercent) = + body(Body.ofUnitWithPercent(unitWithPercent)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingTieredWithProrationPrice(newFloatingTieredWithProrationPrice)`. - */ - fun body(newFloatingTieredWithProrationPrice: Body.NewFloatingTieredWithProrationPrice) = - body(Body.ofNewFloatingTieredWithProrationPrice(newFloatingTieredWithProrationPrice)) + /** Alias for calling [body] with `Body.ofTieredWithProration(tieredWithProration)`. */ + fun body(tieredWithProration: Body.TieredWithProration) = + body(Body.ofTieredWithProration(tieredWithProration)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingUnitWithProrationPrice(newFloatingUnitWithProrationPrice)`. - */ - fun body(newFloatingUnitWithProrationPrice: Body.NewFloatingUnitWithProrationPrice) = - body(Body.ofNewFloatingUnitWithProrationPrice(newFloatingUnitWithProrationPrice)) + /** Alias for calling [body] with `Body.ofUnitWithProration(unitWithProration)`. */ + fun body(unitWithProration: Body.UnitWithProration) = + body(Body.ofUnitWithProration(unitWithProration)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingGroupedAllocationPrice(newFloatingGroupedAllocationPrice)`. - */ - fun body(newFloatingGroupedAllocationPrice: Body.NewFloatingGroupedAllocationPrice) = - body(Body.ofNewFloatingGroupedAllocationPrice(newFloatingGroupedAllocationPrice)) + /** Alias for calling [body] with `Body.ofGroupedAllocation(groupedAllocation)`. */ + fun body(groupedAllocation: Body.GroupedAllocation) = + body(Body.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [body] with - * `Body.ofNewFloatingGroupedWithProratedMinimumPrice(newFloatingGroupedWithProratedMinimumPrice)`. + * `Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun body( - newFloatingGroupedWithProratedMinimumPrice: - Body.NewFloatingGroupedWithProratedMinimumPrice - ) = - body( - Body.ofNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice - ) - ) + fun body(groupedWithProratedMinimum: Body.GroupedWithProratedMinimum) = + body(Body.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [body] with - * `Body.ofNewFloatingGroupedWithMeteredMinimumPrice(newFloatingGroupedWithMeteredMinimumPrice)`. + * `Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun body( - newFloatingGroupedWithMeteredMinimumPrice: - Body.NewFloatingGroupedWithMeteredMinimumPrice - ) = - body( - Body.ofNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice - ) - ) + fun body(groupedWithMeteredMinimum: Body.GroupedWithMeteredMinimum) = + body(Body.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingMatrixWithDisplayNamePrice(newFloatingMatrixWithDisplayNamePrice)`. - */ - fun body( - newFloatingMatrixWithDisplayNamePrice: Body.NewFloatingMatrixWithDisplayNamePrice - ) = - body( - Body.ofNewFloatingMatrixWithDisplayNamePrice(newFloatingMatrixWithDisplayNamePrice) - ) + /** Alias for calling [body] with `Body.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ + fun body(matrixWithDisplayName: Body.MatrixWithDisplayName) = + body(Body.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingBulkWithProrationPrice(newFloatingBulkWithProrationPrice)`. - */ - fun body(newFloatingBulkWithProrationPrice: Body.NewFloatingBulkWithProrationPrice) = - body(Body.ofNewFloatingBulkWithProrationPrice(newFloatingBulkWithProrationPrice)) + /** Alias for calling [body] with `Body.ofBulkWithProration(bulkWithProration)`. */ + fun body(bulkWithProration: Body.BulkWithProration) = + body(Body.ofBulkWithProration(bulkWithProration)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingGroupedTieredPackagePrice(newFloatingGroupedTieredPackagePrice)`. - */ - fun body(newFloatingGroupedTieredPackagePrice: Body.NewFloatingGroupedTieredPackagePrice) = - body(Body.ofNewFloatingGroupedTieredPackagePrice(newFloatingGroupedTieredPackagePrice)) + /** Alias for calling [body] with `Body.ofGroupedTieredPackage(groupedTieredPackage)`. */ + fun body(groupedTieredPackage: Body.GroupedTieredPackage) = + body(Body.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [body] with - * `Body.ofNewFloatingScalableMatrixWithUnitPricingPrice(newFloatingScalableMatrixWithUnitPricingPrice)`. + * `Body.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun body( - newFloatingScalableMatrixWithUnitPricingPrice: - Body.NewFloatingScalableMatrixWithUnitPricingPrice - ) = - body( - Body.ofNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice - ) - ) + fun body(scalableMatrixWithUnitPricing: Body.ScalableMatrixWithUnitPricing) = + body(Body.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [body] with - * `Body.ofNewFloatingScalableMatrixWithTieredPricingPrice(newFloatingScalableMatrixWithTieredPricingPrice)`. + * `Body.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun body( - newFloatingScalableMatrixWithTieredPricingPrice: - Body.NewFloatingScalableMatrixWithTieredPricingPrice - ) = - body( - Body.ofNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice - ) - ) + fun body(scalableMatrixWithTieredPricing: Body.ScalableMatrixWithTieredPricing) = + body(Body.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) - /** - * Alias for calling [body] with - * `Body.ofNewFloatingCumulativeGroupedBulkPrice(newFloatingCumulativeGroupedBulkPrice)`. - */ - fun body( - newFloatingCumulativeGroupedBulkPrice: Body.NewFloatingCumulativeGroupedBulkPrice - ) = - body( - Body.ofNewFloatingCumulativeGroupedBulkPrice(newFloatingCumulativeGroupedBulkPrice) - ) + /** Alias for calling [body] with `Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ + fun body(cumulativeGroupedBulk: Body.CumulativeGroupedBulk) = + body(Body.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -450,420 +335,283 @@ private constructor( @JsonSerialize(using = Body.Serializer::class) class Body private constructor( - private val newFloatingUnitPrice: NewFloatingUnitPrice? = null, - private val newFloatingPackagePrice: NewFloatingPackagePrice? = null, - private val newFloatingMatrixPrice: NewFloatingMatrixPrice? = null, - private val newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice? = - null, - private val newFloatingTieredPrice: NewFloatingTieredPrice? = null, - private val newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice? = null, - private val newFloatingBpsPrice: NewFloatingBpsPrice? = null, - private val newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice? = null, - private val newFloatingBulkPrice: NewFloatingBulkPrice? = null, - private val newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice? = - null, - private val newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice? = null, - private val newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice? = null, - private val newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice? = - null, - private val newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice? = null, - private val newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice? = - null, - private val newFloatingTieredPackageWithMinimumPrice: - NewFloatingTieredPackageWithMinimumPrice? = - null, - private val newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice? = null, - private val newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice? = - null, - private val newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice? = null, - private val newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice? = null, - private val newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice? = - null, - private val newFloatingGroupedWithMeteredMinimumPrice: - NewFloatingGroupedWithMeteredMinimumPrice? = - null, - private val newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice? = - null, - private val newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice? = null, - private val newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice? = - null, - private val newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice? = - null, - private val newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice? = - null, - private val newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice? = - null, + private val unit: Unit? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, + private val tiered: Tiered? = null, + private val tieredBps: TieredBps? = null, + private val bps: Bps? = null, + private val bulkBps: BulkBps? = null, + private val bulk: Bulk? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val groupedTiered: GroupedTiered? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val _json: JsonValue? = null, ) { - fun newFloatingUnitPrice(): Optional = - Optional.ofNullable(newFloatingUnitPrice) + fun unit(): Optional = Optional.ofNullable(unit) - fun newFloatingPackagePrice(): Optional = - Optional.ofNullable(newFloatingPackagePrice) + fun package_(): Optional = Optional.ofNullable(package_) - fun newFloatingMatrixPrice(): Optional = - Optional.ofNullable(newFloatingMatrixPrice) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun newFloatingMatrixWithAllocationPrice(): Optional = - Optional.ofNullable(newFloatingMatrixWithAllocationPrice) + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) - fun newFloatingTieredPrice(): Optional = - Optional.ofNullable(newFloatingTieredPrice) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun newFloatingTieredBpsPrice(): Optional = - Optional.ofNullable(newFloatingTieredBpsPrice) + fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - fun newFloatingBpsPrice(): Optional = - Optional.ofNullable(newFloatingBpsPrice) + fun bps(): Optional = Optional.ofNullable(bps) - fun newFloatingBulkBpsPrice(): Optional = - Optional.ofNullable(newFloatingBulkBpsPrice) + fun bulkBps(): Optional = Optional.ofNullable(bulkBps) - fun newFloatingBulkPrice(): Optional = - Optional.ofNullable(newFloatingBulkPrice) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun newFloatingThresholdTotalAmountPrice(): Optional = - Optional.ofNullable(newFloatingThresholdTotalAmountPrice) + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) - fun newFloatingTieredPackagePrice(): Optional = - Optional.ofNullable(newFloatingTieredPackagePrice) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun newFloatingGroupedTieredPrice(): Optional = - Optional.ofNullable(newFloatingGroupedTieredPrice) + fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) - fun newFloatingMaxGroupTieredPackagePrice(): - Optional = - Optional.ofNullable(newFloatingMaxGroupTieredPackagePrice) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) - fun newFloatingTieredWithMinimumPrice(): Optional = - Optional.ofNullable(newFloatingTieredWithMinimumPrice) + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) - fun newFloatingPackageWithAllocationPrice(): - Optional = - Optional.ofNullable(newFloatingPackageWithAllocationPrice) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) - fun newFloatingTieredPackageWithMinimumPrice(): - Optional = - Optional.ofNullable(newFloatingTieredPackageWithMinimumPrice) + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) - fun newFloatingUnitWithPercentPrice(): Optional = - Optional.ofNullable(newFloatingUnitWithPercentPrice) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun newFloatingTieredWithProrationPrice(): Optional = - Optional.ofNullable(newFloatingTieredWithProrationPrice) + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) - fun newFloatingUnitWithProrationPrice(): Optional = - Optional.ofNullable(newFloatingUnitWithProrationPrice) + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) - fun newFloatingGroupedAllocationPrice(): Optional = - Optional.ofNullable(newFloatingGroupedAllocationPrice) + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) - fun newFloatingGroupedWithProratedMinimumPrice(): - Optional = - Optional.ofNullable(newFloatingGroupedWithProratedMinimumPrice) + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) - fun newFloatingGroupedWithMeteredMinimumPrice(): - Optional = - Optional.ofNullable(newFloatingGroupedWithMeteredMinimumPrice) + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) - fun newFloatingMatrixWithDisplayNamePrice(): - Optional = - Optional.ofNullable(newFloatingMatrixWithDisplayNamePrice) + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) - fun newFloatingBulkWithProrationPrice(): Optional = - Optional.ofNullable(newFloatingBulkWithProrationPrice) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) - fun newFloatingGroupedTieredPackagePrice(): Optional = - Optional.ofNullable(newFloatingGroupedTieredPackagePrice) + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) - fun newFloatingScalableMatrixWithUnitPricingPrice(): - Optional = - Optional.ofNullable(newFloatingScalableMatrixWithUnitPricingPrice) + fun scalableMatrixWithUnitPricing(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) - fun newFloatingScalableMatrixWithTieredPricingPrice(): - Optional = - Optional.ofNullable(newFloatingScalableMatrixWithTieredPricingPrice) + fun scalableMatrixWithTieredPricing(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) - fun newFloatingCumulativeGroupedBulkPrice(): - Optional = - Optional.ofNullable(newFloatingCumulativeGroupedBulkPrice) + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) - fun isNewFloatingUnitPrice(): Boolean = newFloatingUnitPrice != null + fun isUnit(): Boolean = unit != null - fun isNewFloatingPackagePrice(): Boolean = newFloatingPackagePrice != null + fun isPackage(): Boolean = package_ != null - fun isNewFloatingMatrixPrice(): Boolean = newFloatingMatrixPrice != null + fun isMatrix(): Boolean = matrix != null - fun isNewFloatingMatrixWithAllocationPrice(): Boolean = - newFloatingMatrixWithAllocationPrice != null + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun isNewFloatingTieredPrice(): Boolean = newFloatingTieredPrice != null + fun isTiered(): Boolean = tiered != null - fun isNewFloatingTieredBpsPrice(): Boolean = newFloatingTieredBpsPrice != null + fun isTieredBps(): Boolean = tieredBps != null - fun isNewFloatingBpsPrice(): Boolean = newFloatingBpsPrice != null + fun isBps(): Boolean = bps != null - fun isNewFloatingBulkBpsPrice(): Boolean = newFloatingBulkBpsPrice != null + fun isBulkBps(): Boolean = bulkBps != null - fun isNewFloatingBulkPrice(): Boolean = newFloatingBulkPrice != null + fun isBulk(): Boolean = bulk != null - fun isNewFloatingThresholdTotalAmountPrice(): Boolean = - newFloatingThresholdTotalAmountPrice != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isNewFloatingTieredPackagePrice(): Boolean = newFloatingTieredPackagePrice != null + fun isTieredPackage(): Boolean = tieredPackage != null - fun isNewFloatingGroupedTieredPrice(): Boolean = newFloatingGroupedTieredPrice != null + fun isGroupedTiered(): Boolean = groupedTiered != null - fun isNewFloatingMaxGroupTieredPackagePrice(): Boolean = - newFloatingMaxGroupTieredPackagePrice != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isNewFloatingTieredWithMinimumPrice(): Boolean = - newFloatingTieredWithMinimumPrice != null + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isNewFloatingPackageWithAllocationPrice(): Boolean = - newFloatingPackageWithAllocationPrice != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun isNewFloatingTieredPackageWithMinimumPrice(): Boolean = - newFloatingTieredPackageWithMinimumPrice != null + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - fun isNewFloatingUnitWithPercentPrice(): Boolean = newFloatingUnitWithPercentPrice != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun isNewFloatingTieredWithProrationPrice(): Boolean = - newFloatingTieredWithProrationPrice != null + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun isNewFloatingUnitWithProrationPrice(): Boolean = - newFloatingUnitWithProrationPrice != null + fun isUnitWithProration(): Boolean = unitWithProration != null - fun isNewFloatingGroupedAllocationPrice(): Boolean = - newFloatingGroupedAllocationPrice != null + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isNewFloatingGroupedWithProratedMinimumPrice(): Boolean = - newFloatingGroupedWithProratedMinimumPrice != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun isNewFloatingGroupedWithMeteredMinimumPrice(): Boolean = - newFloatingGroupedWithMeteredMinimumPrice != null + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isNewFloatingMatrixWithDisplayNamePrice(): Boolean = - newFloatingMatrixWithDisplayNamePrice != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isNewFloatingBulkWithProrationPrice(): Boolean = - newFloatingBulkWithProrationPrice != null + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isNewFloatingGroupedTieredPackagePrice(): Boolean = - newFloatingGroupedTieredPackagePrice != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun isNewFloatingScalableMatrixWithUnitPricingPrice(): Boolean = - newFloatingScalableMatrixWithUnitPricingPrice != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isNewFloatingScalableMatrixWithTieredPricingPrice(): Boolean = - newFloatingScalableMatrixWithTieredPricingPrice != null + fun isScalableMatrixWithTieredPricing(): Boolean = scalableMatrixWithTieredPricing != null - fun isNewFloatingCumulativeGroupedBulkPrice(): Boolean = - newFloatingCumulativeGroupedBulkPrice != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun asNewFloatingUnitPrice(): NewFloatingUnitPrice = - newFloatingUnitPrice.getOrThrow("newFloatingUnitPrice") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asNewFloatingPackagePrice(): NewFloatingPackagePrice = - newFloatingPackagePrice.getOrThrow("newFloatingPackagePrice") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asNewFloatingMatrixPrice(): NewFloatingMatrixPrice = - newFloatingMatrixPrice.getOrThrow("newFloatingMatrixPrice") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asNewFloatingMatrixWithAllocationPrice(): NewFloatingMatrixWithAllocationPrice = - newFloatingMatrixWithAllocationPrice.getOrThrow("newFloatingMatrixWithAllocationPrice") + fun asMatrixWithAllocation(): MatrixWithAllocation = + matrixWithAllocation.getOrThrow("matrixWithAllocation") - fun asNewFloatingTieredPrice(): NewFloatingTieredPrice = - newFloatingTieredPrice.getOrThrow("newFloatingTieredPrice") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asNewFloatingTieredBpsPrice(): NewFloatingTieredBpsPrice = - newFloatingTieredBpsPrice.getOrThrow("newFloatingTieredBpsPrice") + fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - fun asNewFloatingBpsPrice(): NewFloatingBpsPrice = - newFloatingBpsPrice.getOrThrow("newFloatingBpsPrice") + fun asBps(): Bps = bps.getOrThrow("bps") - fun asNewFloatingBulkBpsPrice(): NewFloatingBulkBpsPrice = - newFloatingBulkBpsPrice.getOrThrow("newFloatingBulkBpsPrice") + fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") - fun asNewFloatingBulkPrice(): NewFloatingBulkPrice = - newFloatingBulkPrice.getOrThrow("newFloatingBulkPrice") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") - fun asNewFloatingThresholdTotalAmountPrice(): NewFloatingThresholdTotalAmountPrice = - newFloatingThresholdTotalAmountPrice.getOrThrow("newFloatingThresholdTotalAmountPrice") + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asNewFloatingTieredPackagePrice(): NewFloatingTieredPackagePrice = - newFloatingTieredPackagePrice.getOrThrow("newFloatingTieredPackagePrice") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asNewFloatingGroupedTieredPrice(): NewFloatingGroupedTieredPrice = - newFloatingGroupedTieredPrice.getOrThrow("newFloatingGroupedTieredPrice") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asNewFloatingMaxGroupTieredPackagePrice(): NewFloatingMaxGroupTieredPackagePrice = - newFloatingMaxGroupTieredPackagePrice.getOrThrow( - "newFloatingMaxGroupTieredPackagePrice" - ) + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asNewFloatingTieredWithMinimumPrice(): NewFloatingTieredWithMinimumPrice = - newFloatingTieredWithMinimumPrice.getOrThrow("newFloatingTieredWithMinimumPrice") + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asNewFloatingPackageWithAllocationPrice(): NewFloatingPackageWithAllocationPrice = - newFloatingPackageWithAllocationPrice.getOrThrow( - "newFloatingPackageWithAllocationPrice" - ) + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") - fun asNewFloatingTieredPackageWithMinimumPrice(): NewFloatingTieredPackageWithMinimumPrice = - newFloatingTieredPackageWithMinimumPrice.getOrThrow( - "newFloatingTieredPackageWithMinimumPrice" - ) + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun asNewFloatingUnitWithPercentPrice(): NewFloatingUnitWithPercentPrice = - newFloatingUnitWithPercentPrice.getOrThrow("newFloatingUnitWithPercentPrice") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asNewFloatingTieredWithProrationPrice(): NewFloatingTieredWithProrationPrice = - newFloatingTieredWithProrationPrice.getOrThrow("newFloatingTieredWithProrationPrice") + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") - fun asNewFloatingUnitWithProrationPrice(): NewFloatingUnitWithProrationPrice = - newFloatingUnitWithProrationPrice.getOrThrow("newFloatingUnitWithProrationPrice") + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") - fun asNewFloatingGroupedAllocationPrice(): NewFloatingGroupedAllocationPrice = - newFloatingGroupedAllocationPrice.getOrThrow("newFloatingGroupedAllocationPrice") + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") - fun asNewFloatingGroupedWithProratedMinimumPrice(): - NewFloatingGroupedWithProratedMinimumPrice = - newFloatingGroupedWithProratedMinimumPrice.getOrThrow( - "newFloatingGroupedWithProratedMinimumPrice" - ) + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asNewFloatingGroupedWithMeteredMinimumPrice(): - NewFloatingGroupedWithMeteredMinimumPrice = - newFloatingGroupedWithMeteredMinimumPrice.getOrThrow( - "newFloatingGroupedWithMeteredMinimumPrice" - ) + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - fun asNewFloatingMatrixWithDisplayNamePrice(): NewFloatingMatrixWithDisplayNamePrice = - newFloatingMatrixWithDisplayNamePrice.getOrThrow( - "newFloatingMatrixWithDisplayNamePrice" - ) + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asNewFloatingBulkWithProrationPrice(): NewFloatingBulkWithProrationPrice = - newFloatingBulkWithProrationPrice.getOrThrow("newFloatingBulkWithProrationPrice") + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") - fun asNewFloatingGroupedTieredPackagePrice(): NewFloatingGroupedTieredPackagePrice = - newFloatingGroupedTieredPackagePrice.getOrThrow("newFloatingGroupedTieredPackagePrice") + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asNewFloatingScalableMatrixWithUnitPricingPrice(): - NewFloatingScalableMatrixWithUnitPricingPrice = - newFloatingScalableMatrixWithUnitPricingPrice.getOrThrow( - "newFloatingScalableMatrixWithUnitPricingPrice" - ) + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asNewFloatingScalableMatrixWithTieredPricingPrice(): - NewFloatingScalableMatrixWithTieredPricingPrice = - newFloatingScalableMatrixWithTieredPricingPrice.getOrThrow( - "newFloatingScalableMatrixWithTieredPricingPrice" - ) + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asNewFloatingCumulativeGroupedBulkPrice(): NewFloatingCumulativeGroupedBulkPrice = - newFloatingCumulativeGroupedBulkPrice.getOrThrow( - "newFloatingCumulativeGroupedBulkPrice" - ) + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newFloatingUnitPrice != null -> - visitor.visitNewFloatingUnitPrice(newFloatingUnitPrice) - newFloatingPackagePrice != null -> - visitor.visitNewFloatingPackagePrice(newFloatingPackagePrice) - newFloatingMatrixPrice != null -> - visitor.visitNewFloatingMatrixPrice(newFloatingMatrixPrice) - newFloatingMatrixWithAllocationPrice != null -> - visitor.visitNewFloatingMatrixWithAllocationPrice( - newFloatingMatrixWithAllocationPrice - ) - newFloatingTieredPrice != null -> - visitor.visitNewFloatingTieredPrice(newFloatingTieredPrice) - newFloatingTieredBpsPrice != null -> - visitor.visitNewFloatingTieredBpsPrice(newFloatingTieredBpsPrice) - newFloatingBpsPrice != null -> visitor.visitNewFloatingBpsPrice(newFloatingBpsPrice) - newFloatingBulkBpsPrice != null -> - visitor.visitNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice) - newFloatingBulkPrice != null -> - visitor.visitNewFloatingBulkPrice(newFloatingBulkPrice) - newFloatingThresholdTotalAmountPrice != null -> - visitor.visitNewFloatingThresholdTotalAmountPrice( - newFloatingThresholdTotalAmountPrice - ) - newFloatingTieredPackagePrice != null -> - visitor.visitNewFloatingTieredPackagePrice(newFloatingTieredPackagePrice) - newFloatingGroupedTieredPrice != null -> - visitor.visitNewFloatingGroupedTieredPrice(newFloatingGroupedTieredPrice) - newFloatingMaxGroupTieredPackagePrice != null -> - visitor.visitNewFloatingMaxGroupTieredPackagePrice( - newFloatingMaxGroupTieredPackagePrice - ) - newFloatingTieredWithMinimumPrice != null -> - visitor.visitNewFloatingTieredWithMinimumPrice( - newFloatingTieredWithMinimumPrice - ) - newFloatingPackageWithAllocationPrice != null -> - visitor.visitNewFloatingPackageWithAllocationPrice( - newFloatingPackageWithAllocationPrice - ) - newFloatingTieredPackageWithMinimumPrice != null -> - visitor.visitNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice - ) - newFloatingUnitWithPercentPrice != null -> - visitor.visitNewFloatingUnitWithPercentPrice(newFloatingUnitWithPercentPrice) - newFloatingTieredWithProrationPrice != null -> - visitor.visitNewFloatingTieredWithProrationPrice( - newFloatingTieredWithProrationPrice - ) - newFloatingUnitWithProrationPrice != null -> - visitor.visitNewFloatingUnitWithProrationPrice( - newFloatingUnitWithProrationPrice - ) - newFloatingGroupedAllocationPrice != null -> - visitor.visitNewFloatingGroupedAllocationPrice( - newFloatingGroupedAllocationPrice - ) - newFloatingGroupedWithProratedMinimumPrice != null -> - visitor.visitNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice - ) - newFloatingGroupedWithMeteredMinimumPrice != null -> - visitor.visitNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice - ) - newFloatingMatrixWithDisplayNamePrice != null -> - visitor.visitNewFloatingMatrixWithDisplayNamePrice( - newFloatingMatrixWithDisplayNamePrice - ) - newFloatingBulkWithProrationPrice != null -> - visitor.visitNewFloatingBulkWithProrationPrice( - newFloatingBulkWithProrationPrice - ) - newFloatingGroupedTieredPackagePrice != null -> - visitor.visitNewFloatingGroupedTieredPackagePrice( - newFloatingGroupedTieredPackagePrice - ) - newFloatingScalableMatrixWithUnitPricingPrice != null -> - visitor.visitNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice - ) - newFloatingScalableMatrixWithTieredPricingPrice != null -> - visitor.visitNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice - ) - newFloatingCumulativeGroupedBulkPrice != null -> - visitor.visitNewFloatingCumulativeGroupedBulkPrice( - newFloatingCumulativeGroupedBulkPrice - ) + 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) + 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) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + 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) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) else -> visitor.unknown(_json) } @@ -875,178 +623,143 @@ private constructor( } accept( - object : Visitor { - override fun visitNewFloatingUnitPrice( - newFloatingUnitPrice: NewFloatingUnitPrice - ) { - newFloatingUnitPrice.validate() + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() } - override fun visitNewFloatingPackagePrice( - newFloatingPackagePrice: NewFloatingPackagePrice - ) { - newFloatingPackagePrice.validate() + override fun visitPackage(package_: Package) { + package_.validate() } - override fun visitNewFloatingMatrixPrice( - newFloatingMatrixPrice: NewFloatingMatrixPrice - ) { - newFloatingMatrixPrice.validate() + override fun visitMatrix(matrix: Matrix) { + matrix.validate() } - override fun visitNewFloatingMatrixWithAllocationPrice( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation ) { - newFloatingMatrixWithAllocationPrice.validate() + matrixWithAllocation.validate() } - override fun visitNewFloatingTieredPrice( - newFloatingTieredPrice: NewFloatingTieredPrice - ) { - newFloatingTieredPrice.validate() + override fun visitTiered(tiered: Tiered) { + tiered.validate() } - override fun visitNewFloatingTieredBpsPrice( - newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice - ) { - newFloatingTieredBpsPrice.validate() + override fun visitTieredBps(tieredBps: TieredBps) { + tieredBps.validate() } - override fun visitNewFloatingBpsPrice( - newFloatingBpsPrice: NewFloatingBpsPrice - ) { - newFloatingBpsPrice.validate() + override fun visitBps(bps: Bps) { + bps.validate() } - override fun visitNewFloatingBulkBpsPrice( - newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice - ) { - newFloatingBulkBpsPrice.validate() + override fun visitBulkBps(bulkBps: BulkBps) { + bulkBps.validate() } - override fun visitNewFloatingBulkPrice( - newFloatingBulkPrice: NewFloatingBulkPrice - ) { - newFloatingBulkPrice.validate() + override fun visitBulk(bulk: Bulk) { + bulk.validate() } - override fun visitNewFloatingThresholdTotalAmountPrice( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount ) { - newFloatingThresholdTotalAmountPrice.validate() + thresholdTotalAmount.validate() } - override fun visitNewFloatingTieredPackagePrice( - newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice - ) { - newFloatingTieredPackagePrice.validate() + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() } - override fun visitNewFloatingGroupedTieredPrice( - newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice - ) { - newFloatingGroupedTieredPrice.validate() + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { + groupedTiered.validate() } - override fun visitNewFloatingMaxGroupTieredPackagePrice( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage ) { - newFloatingMaxGroupTieredPackagePrice.validate() + maxGroupTieredPackage.validate() } - override fun visitNewFloatingTieredWithMinimumPrice( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ) { - newFloatingTieredWithMinimumPrice.validate() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() } - override fun visitNewFloatingPackageWithAllocationPrice( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation ) { - newFloatingPackageWithAllocationPrice.validate() + packageWithAllocation.validate() } - override fun visitNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice: - NewFloatingTieredPackageWithMinimumPrice + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum ) { - newFloatingTieredPackageWithMinimumPrice.validate() + tieredPackageWithMinimum.validate() } - override fun visitNewFloatingUnitWithPercentPrice( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ) { - newFloatingUnitWithPercentPrice.validate() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() } - override fun visitNewFloatingTieredWithProrationPrice( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration ) { - newFloatingTieredWithProrationPrice.validate() + tieredWithProration.validate() } - override fun visitNewFloatingUnitWithProrationPrice( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ) { - newFloatingUnitWithProrationPrice.validate() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() } - override fun visitNewFloatingGroupedAllocationPrice( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ) { - newFloatingGroupedAllocationPrice.validate() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() } - override fun visitNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { - newFloatingGroupedWithProratedMinimumPrice.validate() + groupedWithProratedMinimum.validate() } - override fun visitNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice: - NewFloatingGroupedWithMeteredMinimumPrice + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { - newFloatingGroupedWithMeteredMinimumPrice.validate() + groupedWithMeteredMinimum.validate() } - override fun visitNewFloatingMatrixWithDisplayNamePrice( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName ) { - newFloatingMatrixWithDisplayNamePrice.validate() + matrixWithDisplayName.validate() } - override fun visitNewFloatingBulkWithProrationPrice( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ) { - newFloatingBulkWithProrationPrice.validate() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() } - override fun visitNewFloatingGroupedTieredPackagePrice( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage ) { - newFloatingGroupedTieredPackagePrice.validate() + groupedTieredPackage.validate() } - override fun visitNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { - newFloatingScalableMatrixWithUnitPricingPrice.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { - newFloatingScalableMatrixWithTieredPricingPrice.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitNewFloatingCumulativeGroupedBulkPrice( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk ) { - newFloatingCumulativeGroupedBulkPrice.validate() + cumulativeGroupedBulk.validate() } } ) @@ -1071,122 +784,94 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewFloatingUnitPrice( - newFloatingUnitPrice: NewFloatingUnitPrice - ) = newFloatingUnitPrice.validity() - - override fun visitNewFloatingPackagePrice( - newFloatingPackagePrice: NewFloatingPackagePrice - ) = newFloatingPackagePrice.validity() - - override fun visitNewFloatingMatrixPrice( - newFloatingMatrixPrice: NewFloatingMatrixPrice - ) = newFloatingMatrixPrice.validity() - - override fun visitNewFloatingMatrixWithAllocationPrice( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ) = newFloatingMatrixWithAllocationPrice.validity() - - override fun visitNewFloatingTieredPrice( - newFloatingTieredPrice: NewFloatingTieredPrice - ) = newFloatingTieredPrice.validity() - - override fun visitNewFloatingTieredBpsPrice( - newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice - ) = newFloatingTieredBpsPrice.validity() - - override fun visitNewFloatingBpsPrice( - newFloatingBpsPrice: NewFloatingBpsPrice - ) = newFloatingBpsPrice.validity() - - override fun visitNewFloatingBulkBpsPrice( - newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice - ) = newFloatingBulkBpsPrice.validity() - - override fun visitNewFloatingBulkPrice( - newFloatingBulkPrice: NewFloatingBulkPrice - ) = newFloatingBulkPrice.validity() - - override fun visitNewFloatingThresholdTotalAmountPrice( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ) = newFloatingThresholdTotalAmountPrice.validity() - - override fun visitNewFloatingTieredPackagePrice( - newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice - ) = newFloatingTieredPackagePrice.validity() - - override fun visitNewFloatingGroupedTieredPrice( - newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice - ) = newFloatingGroupedTieredPrice.validity() - - override fun visitNewFloatingMaxGroupTieredPackagePrice( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ) = newFloatingMaxGroupTieredPackagePrice.validity() - - override fun visitNewFloatingTieredWithMinimumPrice( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ) = newFloatingTieredWithMinimumPrice.validity() - - override fun visitNewFloatingPackageWithAllocationPrice( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ) = newFloatingPackageWithAllocationPrice.validity() - - override fun visitNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice: - NewFloatingTieredPackageWithMinimumPrice - ) = newFloatingTieredPackageWithMinimumPrice.validity() - - override fun visitNewFloatingUnitWithPercentPrice( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ) = newFloatingUnitWithPercentPrice.validity() - - override fun visitNewFloatingTieredWithProrationPrice( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ) = newFloatingTieredWithProrationPrice.validity() - - override fun visitNewFloatingUnitWithProrationPrice( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ) = newFloatingUnitWithProrationPrice.validity() - - override fun visitNewFloatingGroupedAllocationPrice( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ) = newFloatingGroupedAllocationPrice.validity() - - override fun visitNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice - ) = newFloatingGroupedWithProratedMinimumPrice.validity() - - override fun visitNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice: - NewFloatingGroupedWithMeteredMinimumPrice - ) = newFloatingGroupedWithMeteredMinimumPrice.validity() - - override fun visitNewFloatingMatrixWithDisplayNamePrice( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ) = newFloatingMatrixWithDisplayNamePrice.validity() - - override fun visitNewFloatingBulkWithProrationPrice( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ) = newFloatingBulkWithProrationPrice.validity() - - override fun visitNewFloatingGroupedTieredPackagePrice( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ) = newFloatingGroupedTieredPackagePrice.validity() + override fun visitUnit(unit: Unit) = unit.validity() + + override fun visitPackage(package_: Package) = package_.validity() + + override fun visitMatrix(matrix: Matrix) = matrix.validity() + + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) = matrixWithAllocation.validity() + + override fun visitTiered(tiered: Tiered) = tiered.validity() + + override fun visitTieredBps(tieredBps: TieredBps) = tieredBps.validity() + + override fun visitBps(bps: Bps) = bps.validity() + + override fun visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() + + override fun visitBulk(bulk: Bulk) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() + + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = + groupedTiered.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() + + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) = tieredPackageWithMinimum.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() - override fun visitNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice - ) = newFloatingScalableMatrixWithUnitPricingPrice.validity() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() - override fun visitNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice - ) = newFloatingScalableMatrixWithTieredPricingPrice.validity() - - override fun visitNewFloatingCumulativeGroupedBulkPrice( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ) = newFloatingCumulativeGroupedBulkPrice.validity() + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() override fun unknown(json: JsonValue?) = 0 } @@ -1197,331 +882,220 @@ private constructor( return true } - return /* spotless:off */ other is Body && newFloatingUnitPrice == other.newFloatingUnitPrice && newFloatingPackagePrice == other.newFloatingPackagePrice && newFloatingMatrixPrice == other.newFloatingMatrixPrice && newFloatingMatrixWithAllocationPrice == other.newFloatingMatrixWithAllocationPrice && newFloatingTieredPrice == other.newFloatingTieredPrice && newFloatingTieredBpsPrice == other.newFloatingTieredBpsPrice && newFloatingBpsPrice == other.newFloatingBpsPrice && newFloatingBulkBpsPrice == other.newFloatingBulkBpsPrice && newFloatingBulkPrice == other.newFloatingBulkPrice && newFloatingThresholdTotalAmountPrice == other.newFloatingThresholdTotalAmountPrice && newFloatingTieredPackagePrice == other.newFloatingTieredPackagePrice && newFloatingGroupedTieredPrice == other.newFloatingGroupedTieredPrice && newFloatingMaxGroupTieredPackagePrice == other.newFloatingMaxGroupTieredPackagePrice && newFloatingTieredWithMinimumPrice == other.newFloatingTieredWithMinimumPrice && newFloatingPackageWithAllocationPrice == other.newFloatingPackageWithAllocationPrice && newFloatingTieredPackageWithMinimumPrice == other.newFloatingTieredPackageWithMinimumPrice && newFloatingUnitWithPercentPrice == other.newFloatingUnitWithPercentPrice && newFloatingTieredWithProrationPrice == other.newFloatingTieredWithProrationPrice && newFloatingUnitWithProrationPrice == other.newFloatingUnitWithProrationPrice && newFloatingGroupedAllocationPrice == other.newFloatingGroupedAllocationPrice && newFloatingGroupedWithProratedMinimumPrice == other.newFloatingGroupedWithProratedMinimumPrice && newFloatingGroupedWithMeteredMinimumPrice == other.newFloatingGroupedWithMeteredMinimumPrice && newFloatingMatrixWithDisplayNamePrice == other.newFloatingMatrixWithDisplayNamePrice && newFloatingBulkWithProrationPrice == other.newFloatingBulkWithProrationPrice && newFloatingGroupedTieredPackagePrice == other.newFloatingGroupedTieredPackagePrice && newFloatingScalableMatrixWithUnitPricingPrice == other.newFloatingScalableMatrixWithUnitPricingPrice && newFloatingScalableMatrixWithTieredPricingPrice == other.newFloatingScalableMatrixWithTieredPricingPrice && newFloatingCumulativeGroupedBulkPrice == other.newFloatingCumulativeGroupedBulkPrice /* spotless:on */ + 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 */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newFloatingUnitPrice, newFloatingPackagePrice, newFloatingMatrixPrice, newFloatingMatrixWithAllocationPrice, newFloatingTieredPrice, newFloatingTieredBpsPrice, newFloatingBpsPrice, newFloatingBulkBpsPrice, newFloatingBulkPrice, newFloatingThresholdTotalAmountPrice, newFloatingTieredPackagePrice, newFloatingGroupedTieredPrice, newFloatingMaxGroupTieredPackagePrice, newFloatingTieredWithMinimumPrice, newFloatingPackageWithAllocationPrice, newFloatingTieredPackageWithMinimumPrice, newFloatingUnitWithPercentPrice, newFloatingTieredWithProrationPrice, newFloatingUnitWithProrationPrice, newFloatingGroupedAllocationPrice, newFloatingGroupedWithProratedMinimumPrice, newFloatingGroupedWithMeteredMinimumPrice, newFloatingMatrixWithDisplayNamePrice, newFloatingBulkWithProrationPrice, newFloatingGroupedTieredPackagePrice, newFloatingScalableMatrixWithUnitPricingPrice, newFloatingScalableMatrixWithTieredPricingPrice, newFloatingCumulativeGroupedBulkPrice) /* 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 */ override fun toString(): String = when { - newFloatingUnitPrice != null -> "Body{newFloatingUnitPrice=$newFloatingUnitPrice}" - newFloatingPackagePrice != null -> - "Body{newFloatingPackagePrice=$newFloatingPackagePrice}" - newFloatingMatrixPrice != null -> - "Body{newFloatingMatrixPrice=$newFloatingMatrixPrice}" - newFloatingMatrixWithAllocationPrice != null -> - "Body{newFloatingMatrixWithAllocationPrice=$newFloatingMatrixWithAllocationPrice}" - newFloatingTieredPrice != null -> - "Body{newFloatingTieredPrice=$newFloatingTieredPrice}" - newFloatingTieredBpsPrice != null -> - "Body{newFloatingTieredBpsPrice=$newFloatingTieredBpsPrice}" - newFloatingBpsPrice != null -> "Body{newFloatingBpsPrice=$newFloatingBpsPrice}" - newFloatingBulkBpsPrice != null -> - "Body{newFloatingBulkBpsPrice=$newFloatingBulkBpsPrice}" - newFloatingBulkPrice != null -> "Body{newFloatingBulkPrice=$newFloatingBulkPrice}" - newFloatingThresholdTotalAmountPrice != null -> - "Body{newFloatingThresholdTotalAmountPrice=$newFloatingThresholdTotalAmountPrice}" - newFloatingTieredPackagePrice != null -> - "Body{newFloatingTieredPackagePrice=$newFloatingTieredPackagePrice}" - newFloatingGroupedTieredPrice != null -> - "Body{newFloatingGroupedTieredPrice=$newFloatingGroupedTieredPrice}" - newFloatingMaxGroupTieredPackagePrice != null -> - "Body{newFloatingMaxGroupTieredPackagePrice=$newFloatingMaxGroupTieredPackagePrice}" - newFloatingTieredWithMinimumPrice != null -> - "Body{newFloatingTieredWithMinimumPrice=$newFloatingTieredWithMinimumPrice}" - newFloatingPackageWithAllocationPrice != null -> - "Body{newFloatingPackageWithAllocationPrice=$newFloatingPackageWithAllocationPrice}" - newFloatingTieredPackageWithMinimumPrice != null -> - "Body{newFloatingTieredPackageWithMinimumPrice=$newFloatingTieredPackageWithMinimumPrice}" - newFloatingUnitWithPercentPrice != null -> - "Body{newFloatingUnitWithPercentPrice=$newFloatingUnitWithPercentPrice}" - newFloatingTieredWithProrationPrice != null -> - "Body{newFloatingTieredWithProrationPrice=$newFloatingTieredWithProrationPrice}" - newFloatingUnitWithProrationPrice != null -> - "Body{newFloatingUnitWithProrationPrice=$newFloatingUnitWithProrationPrice}" - newFloatingGroupedAllocationPrice != null -> - "Body{newFloatingGroupedAllocationPrice=$newFloatingGroupedAllocationPrice}" - newFloatingGroupedWithProratedMinimumPrice != null -> - "Body{newFloatingGroupedWithProratedMinimumPrice=$newFloatingGroupedWithProratedMinimumPrice}" - newFloatingGroupedWithMeteredMinimumPrice != null -> - "Body{newFloatingGroupedWithMeteredMinimumPrice=$newFloatingGroupedWithMeteredMinimumPrice}" - newFloatingMatrixWithDisplayNamePrice != null -> - "Body{newFloatingMatrixWithDisplayNamePrice=$newFloatingMatrixWithDisplayNamePrice}" - newFloatingBulkWithProrationPrice != null -> - "Body{newFloatingBulkWithProrationPrice=$newFloatingBulkWithProrationPrice}" - newFloatingGroupedTieredPackagePrice != null -> - "Body{newFloatingGroupedTieredPackagePrice=$newFloatingGroupedTieredPackagePrice}" - newFloatingScalableMatrixWithUnitPricingPrice != null -> - "Body{newFloatingScalableMatrixWithUnitPricingPrice=$newFloatingScalableMatrixWithUnitPricingPrice}" - newFloatingScalableMatrixWithTieredPricingPrice != null -> - "Body{newFloatingScalableMatrixWithTieredPricingPrice=$newFloatingScalableMatrixWithTieredPricingPrice}" - newFloatingCumulativeGroupedBulkPrice != null -> - "Body{newFloatingCumulativeGroupedBulkPrice=$newFloatingCumulativeGroupedBulkPrice}" + 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}" + 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}" + tieredPackageWithMinimum != null -> + "Body{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + unitWithPercent != null -> "Body{unitWithPercent=$unitWithPercent}" + tieredWithProration != null -> "Body{tieredWithProration=$tieredWithProration}" + unitWithProration != null -> "Body{unitWithProration=$unitWithProration}" + groupedAllocation != null -> "Body{groupedAllocation=$groupedAllocation}" + groupedWithProratedMinimum != null -> + "Body{groupedWithProratedMinimum=$groupedWithProratedMinimum}" + groupedWithMeteredMinimum != null -> + "Body{groupedWithMeteredMinimum=$groupedWithMeteredMinimum}" + matrixWithDisplayName != null -> + "Body{matrixWithDisplayName=$matrixWithDisplayName}" + bulkWithProration != null -> "Body{bulkWithProration=$bulkWithProration}" + groupedTieredPackage != null -> "Body{groupedTieredPackage=$groupedTieredPackage}" + scalableMatrixWithUnitPricing != null -> + "Body{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Body{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Body{cumulativeGroupedBulk=$cumulativeGroupedBulk}" _json != null -> "Body{_unknown=$_json}" else -> throw IllegalStateException("Invalid Body") } companion object { - @JvmStatic - fun ofNewFloatingUnitPrice(newFloatingUnitPrice: NewFloatingUnitPrice) = - Body(newFloatingUnitPrice = newFloatingUnitPrice) + @JvmStatic fun ofUnit(unit: Unit) = Body(unit = unit) - @JvmStatic - fun ofNewFloatingPackagePrice(newFloatingPackagePrice: NewFloatingPackagePrice) = - Body(newFloatingPackagePrice = newFloatingPackagePrice) + @JvmStatic fun ofPackage(package_: Package) = Body(package_ = package_) - @JvmStatic - fun ofNewFloatingMatrixPrice(newFloatingMatrixPrice: NewFloatingMatrixPrice) = - Body(newFloatingMatrixPrice = newFloatingMatrixPrice) + @JvmStatic fun ofMatrix(matrix: Matrix) = Body(matrix = matrix) @JvmStatic - fun ofNewFloatingMatrixWithAllocationPrice( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ) = Body(newFloatingMatrixWithAllocationPrice = newFloatingMatrixWithAllocationPrice) + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + Body(matrixWithAllocation = matrixWithAllocation) - @JvmStatic - fun ofNewFloatingTieredPrice(newFloatingTieredPrice: NewFloatingTieredPrice) = - Body(newFloatingTieredPrice = newFloatingTieredPrice) + @JvmStatic fun ofTiered(tiered: Tiered) = Body(tiered = tiered) - @JvmStatic - fun ofNewFloatingTieredBpsPrice(newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice) = - Body(newFloatingTieredBpsPrice = newFloatingTieredBpsPrice) + @JvmStatic fun ofTieredBps(tieredBps: TieredBps) = Body(tieredBps = tieredBps) - @JvmStatic - fun ofNewFloatingBpsPrice(newFloatingBpsPrice: NewFloatingBpsPrice) = - Body(newFloatingBpsPrice = newFloatingBpsPrice) + @JvmStatic fun ofBps(bps: Bps) = Body(bps = bps) - @JvmStatic - fun ofNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice) = - Body(newFloatingBulkBpsPrice = newFloatingBulkBpsPrice) + @JvmStatic fun ofBulkBps(bulkBps: BulkBps) = Body(bulkBps = bulkBps) - @JvmStatic - fun ofNewFloatingBulkPrice(newFloatingBulkPrice: NewFloatingBulkPrice) = - Body(newFloatingBulkPrice = newFloatingBulkPrice) + @JvmStatic fun ofBulk(bulk: Bulk) = Body(bulk = bulk) @JvmStatic - fun ofNewFloatingThresholdTotalAmountPrice( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ) = Body(newFloatingThresholdTotalAmountPrice = newFloatingThresholdTotalAmountPrice) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + Body(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofNewFloatingTieredPackagePrice( - newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice - ) = Body(newFloatingTieredPackagePrice = newFloatingTieredPackagePrice) + fun ofTieredPackage(tieredPackage: TieredPackage) = Body(tieredPackage = tieredPackage) @JvmStatic - fun ofNewFloatingGroupedTieredPrice( - newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice - ) = Body(newFloatingGroupedTieredPrice = newFloatingGroupedTieredPrice) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = Body(groupedTiered = groupedTiered) @JvmStatic - fun ofNewFloatingMaxGroupTieredPackagePrice( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ) = Body(newFloatingMaxGroupTieredPackagePrice = newFloatingMaxGroupTieredPackagePrice) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + Body(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic - fun ofNewFloatingTieredWithMinimumPrice( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ) = Body(newFloatingTieredWithMinimumPrice = newFloatingTieredWithMinimumPrice) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + Body(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofNewFloatingPackageWithAllocationPrice( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ) = Body(newFloatingPackageWithAllocationPrice = newFloatingPackageWithAllocationPrice) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + Body(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice: NewFloatingTieredPackageWithMinimumPrice - ) = - Body( - newFloatingTieredPackageWithMinimumPrice = - newFloatingTieredPackageWithMinimumPrice - ) + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + Body(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic - fun ofNewFloatingUnitWithPercentPrice( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ) = Body(newFloatingUnitWithPercentPrice = newFloatingUnitWithPercentPrice) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + Body(unitWithPercent = unitWithPercent) @JvmStatic - fun ofNewFloatingTieredWithProrationPrice( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ) = Body(newFloatingTieredWithProrationPrice = newFloatingTieredWithProrationPrice) + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Body(tieredWithProration = tieredWithProration) @JvmStatic - fun ofNewFloatingUnitWithProrationPrice( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ) = Body(newFloatingUnitWithProrationPrice = newFloatingUnitWithProrationPrice) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + Body(unitWithProration = unitWithProration) @JvmStatic - fun ofNewFloatingGroupedAllocationPrice( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ) = Body(newFloatingGroupedAllocationPrice = newFloatingGroupedAllocationPrice) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + Body(groupedAllocation = groupedAllocation) @JvmStatic - fun ofNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice - ) = - Body( - newFloatingGroupedWithProratedMinimumPrice = - newFloatingGroupedWithProratedMinimumPrice - ) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = Body(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice - ) = - Body( - newFloatingGroupedWithMeteredMinimumPrice = - newFloatingGroupedWithMeteredMinimumPrice - ) + fun ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + Body(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofNewFloatingMatrixWithDisplayNamePrice( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ) = Body(newFloatingMatrixWithDisplayNamePrice = newFloatingMatrixWithDisplayNamePrice) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + Body(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofNewFloatingBulkWithProrationPrice( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ) = Body(newFloatingBulkWithProrationPrice = newFloatingBulkWithProrationPrice) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + Body(bulkWithProration = bulkWithProration) @JvmStatic - fun ofNewFloatingGroupedTieredPackagePrice( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ) = Body(newFloatingGroupedTieredPackagePrice = newFloatingGroupedTieredPackagePrice) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + Body(groupedTieredPackage = groupedTieredPackage) @JvmStatic - fun ofNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice - ) = - Body( - newFloatingScalableMatrixWithUnitPricingPrice = - newFloatingScalableMatrixWithUnitPricingPrice - ) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = Body(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic - fun ofNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice - ) = - Body( - newFloatingScalableMatrixWithTieredPricingPrice = - newFloatingScalableMatrixWithTieredPricingPrice - ) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = Body(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofNewFloatingCumulativeGroupedBulkPrice( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ) = Body(newFloatingCumulativeGroupedBulkPrice = newFloatingCumulativeGroupedBulkPrice) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + Body(cumulativeGroupedBulk = cumulativeGroupedBulk) } /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ interface Visitor { - fun visitNewFloatingUnitPrice(newFloatingUnitPrice: NewFloatingUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitNewFloatingPackagePrice(newFloatingPackagePrice: NewFloatingPackagePrice): T + fun visitPackage(package_: Package): T - fun visitNewFloatingMatrixPrice(newFloatingMatrixPrice: NewFloatingMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitNewFloatingMatrixWithAllocationPrice( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ): T + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T - fun visitNewFloatingTieredPrice(newFloatingTieredPrice: NewFloatingTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitNewFloatingTieredBpsPrice( - newFloatingTieredBpsPrice: NewFloatingTieredBpsPrice - ): T + fun visitTieredBps(tieredBps: TieredBps): T - fun visitNewFloatingBpsPrice(newFloatingBpsPrice: NewFloatingBpsPrice): T + fun visitBps(bps: Bps): T - fun visitNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice: NewFloatingBulkBpsPrice): T + fun visitBulkBps(bulkBps: BulkBps): T - fun visitNewFloatingBulkPrice(newFloatingBulkPrice: NewFloatingBulkPrice): T + fun visitBulk(bulk: Bulk): T - fun visitNewFloatingThresholdTotalAmountPrice( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitNewFloatingTieredPackagePrice( - newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice - ): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitNewFloatingGroupedTieredPrice( - newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice - ): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T - fun visitNewFloatingMaxGroupTieredPackagePrice( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T - fun visitNewFloatingTieredWithMinimumPrice( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitNewFloatingPackageWithAllocationPrice( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitNewFloatingTieredPackageWithMinimumPrice( - newFloatingTieredPackageWithMinimumPrice: NewFloatingTieredPackageWithMinimumPrice - ): T + fun visitTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum): T - fun visitNewFloatingUnitWithPercentPrice( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitNewFloatingTieredWithProrationPrice( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitNewFloatingUnitWithProrationPrice( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitNewFloatingGroupedAllocationPrice( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitNewFloatingGroupedWithProratedMinimumPrice( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T - fun visitNewFloatingGroupedWithMeteredMinimumPrice( - newFloatingGroupedWithMeteredMinimumPrice: NewFloatingGroupedWithMeteredMinimumPrice + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T - fun visitNewFloatingMatrixWithDisplayNamePrice( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitNewFloatingBulkWithProrationPrice( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T - fun visitNewFloatingGroupedTieredPackagePrice( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitNewFloatingScalableMatrixWithUnitPricingPrice( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T - fun visitNewFloatingScalableMatrixWithTieredPricingPrice( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitNewFloatingCumulativeGroupedBulkPrice( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T /** * Maps an unknown variant of [Body] to a value of type [T]. @@ -1546,209 +1120,147 @@ private constructor( when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(newFloatingUnitPrice = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(unit = it, _json = json) } ?: Body(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(newFloatingPackagePrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(package_ = it, _json = json) + } ?: Body(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(newFloatingMatrixPrice = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(matrix = it, _json = json) } ?: Body(_json = json) } "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingMatrixWithAllocationPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(matrixWithAllocation = it, _json = json) + } ?: Body(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(newFloatingTieredPrice = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(tiered = it, _json = json) } ?: Body(_json = json) } "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(newFloatingTieredBpsPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(tieredBps = it, _json = json) + } ?: Body(_json = json) } "bps" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(newFloatingBpsPrice = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(bps = it, _json = json) } ?: Body(_json = json) } "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(newFloatingBulkBpsPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(bulkBps = it, _json = json) + } ?: Body(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Body(newFloatingBulkPrice = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(bulk = it, _json = json) } ?: Body(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingThresholdTotalAmountPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(thresholdTotalAmount = it, _json = json) + } ?: Body(_json = json) } "tiered_package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(newFloatingTieredPackagePrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(tieredPackage = it, _json = json) + } ?: Body(_json = json) } "grouped_tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Body(newFloatingGroupedTieredPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(groupedTiered = it, _json = json) + } ?: Body(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingMaxGroupTieredPackagePrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(maxGroupTieredPackage = it, _json = json) + } ?: Body(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingTieredWithMinimumPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(tieredWithMinimum = it, _json = json) + } ?: Body(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingPackageWithAllocationPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(packageWithAllocation = it, _json = json) + } ?: Body(_json = json) } "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body(newFloatingTieredPackageWithMinimumPrice = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(tieredPackageWithMinimum = it, _json = json) } + ?: Body(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingUnitWithPercentPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(unitWithPercent = it, _json = json) + } ?: Body(_json = json) } "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingTieredWithProrationPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(tieredWithProration = it, _json = json) + } ?: Body(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingUnitWithProrationPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(unitWithProration = it, _json = json) + } ?: Body(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingGroupedAllocationPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(groupedAllocation = it, _json = json) + } ?: Body(_json = json) } "grouped_with_prorated_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body(newFloatingGroupedWithProratedMinimumPrice = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(groupedWithProratedMinimum = it, _json = json) } + ?: Body(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body(newFloatingGroupedWithMeteredMinimumPrice = it, _json = json) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(groupedWithMeteredMinimum = it, _json = json) } + ?: Body(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingMatrixWithDisplayNamePrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(matrixWithDisplayName = it, _json = json) + } ?: Body(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingBulkWithProrationPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(bulkWithProration = it, _json = json) + } ?: Body(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingGroupedTieredPackagePrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(groupedTieredPackage = it, _json = json) + } ?: Body(_json = json) } "scalable_matrix_with_unit_pricing" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Body( - newFloatingScalableMatrixWithUnitPricingPrice = it, - _json = json, - ) - } ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Body(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { - Body( - newFloatingScalableMatrixWithTieredPricingPrice = it, - _json = json, - ) - } ?: Body(_json = json) + ?.let { Body(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Body(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Body(newFloatingCumulativeGroupedBulkPrice = it, _json = json) } - ?: Body(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Body(cumulativeGroupedBulk = it, _json = json) + } ?: Body(_json = json) } } @@ -1764,74 +1276,63 @@ private constructor( provider: SerializerProvider, ) { when { - value.newFloatingUnitPrice != null -> - generator.writeObject(value.newFloatingUnitPrice) - value.newFloatingPackagePrice != null -> - generator.writeObject(value.newFloatingPackagePrice) - value.newFloatingMatrixPrice != null -> - generator.writeObject(value.newFloatingMatrixPrice) - value.newFloatingMatrixWithAllocationPrice != null -> - generator.writeObject(value.newFloatingMatrixWithAllocationPrice) - value.newFloatingTieredPrice != null -> - generator.writeObject(value.newFloatingTieredPrice) - value.newFloatingTieredBpsPrice != null -> - generator.writeObject(value.newFloatingTieredBpsPrice) - value.newFloatingBpsPrice != null -> - generator.writeObject(value.newFloatingBpsPrice) - value.newFloatingBulkBpsPrice != null -> - generator.writeObject(value.newFloatingBulkBpsPrice) - value.newFloatingBulkPrice != null -> - generator.writeObject(value.newFloatingBulkPrice) - value.newFloatingThresholdTotalAmountPrice != null -> - generator.writeObject(value.newFloatingThresholdTotalAmountPrice) - value.newFloatingTieredPackagePrice != null -> - generator.writeObject(value.newFloatingTieredPackagePrice) - value.newFloatingGroupedTieredPrice != null -> - generator.writeObject(value.newFloatingGroupedTieredPrice) - value.newFloatingMaxGroupTieredPackagePrice != null -> - generator.writeObject(value.newFloatingMaxGroupTieredPackagePrice) - value.newFloatingTieredWithMinimumPrice != null -> - generator.writeObject(value.newFloatingTieredWithMinimumPrice) - value.newFloatingPackageWithAllocationPrice != null -> - generator.writeObject(value.newFloatingPackageWithAllocationPrice) - value.newFloatingTieredPackageWithMinimumPrice != null -> - generator.writeObject(value.newFloatingTieredPackageWithMinimumPrice) - value.newFloatingUnitWithPercentPrice != null -> - generator.writeObject(value.newFloatingUnitWithPercentPrice) - value.newFloatingTieredWithProrationPrice != null -> - generator.writeObject(value.newFloatingTieredWithProrationPrice) - value.newFloatingUnitWithProrationPrice != null -> - generator.writeObject(value.newFloatingUnitWithProrationPrice) - value.newFloatingGroupedAllocationPrice != null -> - generator.writeObject(value.newFloatingGroupedAllocationPrice) - value.newFloatingGroupedWithProratedMinimumPrice != null -> - generator.writeObject(value.newFloatingGroupedWithProratedMinimumPrice) - value.newFloatingGroupedWithMeteredMinimumPrice != null -> - generator.writeObject(value.newFloatingGroupedWithMeteredMinimumPrice) - value.newFloatingMatrixWithDisplayNamePrice != null -> - generator.writeObject(value.newFloatingMatrixWithDisplayNamePrice) - value.newFloatingBulkWithProrationPrice != null -> - generator.writeObject(value.newFloatingBulkWithProrationPrice) - value.newFloatingGroupedTieredPackagePrice != null -> - generator.writeObject(value.newFloatingGroupedTieredPackagePrice) - value.newFloatingScalableMatrixWithUnitPricingPrice != null -> - generator.writeObject(value.newFloatingScalableMatrixWithUnitPricingPrice) - value.newFloatingScalableMatrixWithTieredPricingPrice != null -> - generator.writeObject(value.newFloatingScalableMatrixWithTieredPricingPrice) - value.newFloatingCumulativeGroupedBulkPrice != null -> - generator.writeObject(value.newFloatingCumulativeGroupedBulkPrice) + 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.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.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.unitWithPercent != null -> generator.writeObject(value.unitWithPercent) + 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.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Body") } } } - class NewFloatingUnitPrice + class Unit private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitConfig: JsonField, private val billableMetricId: JsonField, @@ -1857,9 +1358,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("unit_config") @ExcludeMissing @@ -1939,11 +1438,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -2066,16 +1569,6 @@ private constructor( */ @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]. * @@ -2200,14 +1693,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewFloatingUnitPrice]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` @@ -2215,13 +1707,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingUnitPrice]. */ + /** A builder for [Unit]. */ 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 modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -2238,23 +1730,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingUnitPrice: NewFloatingUnitPrice) = apply { - cadence = newFloatingUnitPrice.cadence - currency = newFloatingUnitPrice.currency - itemId = newFloatingUnitPrice.itemId - modelType = newFloatingUnitPrice.modelType - name = newFloatingUnitPrice.name - unitConfig = newFloatingUnitPrice.unitConfig - billableMetricId = newFloatingUnitPrice.billableMetricId - billedInAdvance = newFloatingUnitPrice.billedInAdvance - billingCycleConfiguration = newFloatingUnitPrice.billingCycleConfiguration - conversionRate = newFloatingUnitPrice.conversionRate - externalPriceId = newFloatingUnitPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingUnitPrice.invoicingCycleConfiguration - metadata = newFloatingUnitPrice.metadata - additionalProperties = newFloatingUnitPrice.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + currency = unit.currency + itemId = unit.itemId + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + metadata = unit.metadata + additionalProperties = unit.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -2293,18 +1785,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -2589,7 +2082,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingUnitPrice]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -2598,19 +2091,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingUnitPrice = - NewFloatingUnitPrice( + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitConfig", unitConfig), billableMetricId, @@ -2628,7 +2120,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingUnitPrice = apply { + fun validate(): Unit = apply { if (validated) { return@apply } @@ -2636,7 +2128,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitConfig().validate() billableMetricId() @@ -2670,7 +2166,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -2839,131 +2335,6 @@ private constructor( 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 UNIT = of("unit") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT - } - - /** - * 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 { - UNIT, - /** - * 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) { - UNIT -> Value.UNIT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - UNIT -> Known.UNIT - 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 UnitConfig private constructor( private val unitAmount: JsonField, @@ -3965,7 +3336,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Unit && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3975,15 +3346,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingPackagePrice + class Package private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageConfig: JsonField, private val billableMetricId: JsonField, @@ -4009,9 +3380,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("package_config") @ExcludeMissing @@ -4091,11 +3460,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -4218,16 +3591,6 @@ private constructor( */ @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]. * @@ -4352,15 +3715,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingPackagePrice]. + * Returns a mutable builder for constructing an instance of [Package]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` @@ -4368,13 +3729,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingPackagePrice]. */ + /** A builder for [Package]. */ 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 modelType: JsonValue = JsonValue.from("package") private var name: JsonField? = null private var packageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -4391,25 +3752,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingPackagePrice: NewFloatingPackagePrice) = apply { - cadence = newFloatingPackagePrice.cadence - currency = newFloatingPackagePrice.currency - itemId = newFloatingPackagePrice.itemId - modelType = newFloatingPackagePrice.modelType - name = newFloatingPackagePrice.name - packageConfig = newFloatingPackagePrice.packageConfig - billableMetricId = newFloatingPackagePrice.billableMetricId - billedInAdvance = newFloatingPackagePrice.billedInAdvance - billingCycleConfiguration = newFloatingPackagePrice.billingCycleConfiguration - conversionRate = newFloatingPackagePrice.conversionRate - externalPriceId = newFloatingPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingPackagePrice.invoicingCycleConfiguration - metadata = newFloatingPackagePrice.metadata - additionalProperties = - newFloatingPackagePrice.additionalProperties.toMutableMap() + internal fun from(package_: Package) = apply { + cadence = package_.cadence + currency = package_.currency + itemId = package_.itemId + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + metadata = package_.metadata + additionalProperties = package_.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -4448,18 +3807,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -4745,7 +4105,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingPackagePrice]. + * Returns an immutable instance of [Package]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -4754,19 +4114,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingPackagePrice = - NewFloatingPackagePrice( + fun build(): Package = + Package( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageConfig", packageConfig), billableMetricId, @@ -4784,7 +4143,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingPackagePrice = apply { + fun validate(): Package = apply { if (validated) { return@apply } @@ -4792,7 +4151,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageConfig().validate() billableMetricId() @@ -4826,7 +4189,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -4995,131 +4358,6 @@ private constructor( 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 PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * 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 { - PACKAGE, - /** - * 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) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - 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 PackageConfig private constructor( private val packageAmount: JsonField, @@ -6171,7 +5409,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Package && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6181,16 +5419,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Package{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingMatrixPrice + class Matrix private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, private val matrixConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -6218,9 +5456,7 @@ private constructor( @JsonProperty("matrix_config") @ExcludeMissing matrixConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -6304,11 +5540,15 @@ private constructor( fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -6434,16 +5674,6 @@ private constructor( @ExcludeMissing fun _matrixConfig(): JsonField = matrixConfig - /** - * 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]. * @@ -6558,8 +5788,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingMatrixPrice]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java @@ -6567,21 +5796,20 @@ private constructor( * .currency() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingMatrixPrice]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null private var itemId: JsonField? = null private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -6597,24 +5825,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingMatrixPrice: NewFloatingMatrixPrice) = apply { - cadence = newFloatingMatrixPrice.cadence - currency = newFloatingMatrixPrice.currency - itemId = newFloatingMatrixPrice.itemId - matrixConfig = newFloatingMatrixPrice.matrixConfig - modelType = newFloatingMatrixPrice.modelType - name = newFloatingMatrixPrice.name - billableMetricId = newFloatingMatrixPrice.billableMetricId - billedInAdvance = newFloatingMatrixPrice.billedInAdvance - billingCycleConfiguration = newFloatingMatrixPrice.billingCycleConfiguration - conversionRate = newFloatingMatrixPrice.conversionRate - externalPriceId = newFloatingMatrixPrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingMatrixPrice.invoicingCycleConfiguration - metadata = newFloatingMatrixPrice.metadata - additionalProperties = - newFloatingMatrixPrice.additionalProperties.toMutableMap() + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + currency = matrix.currency + itemId = matrix.itemId + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + metadata = matrix.metadata + additionalProperties = matrix.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -6667,18 +5894,19 @@ private constructor( this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -6950,7 +6178,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingMatrixPrice]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6960,19 +6188,18 @@ private constructor( * .currency() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingMatrixPrice = - NewFloatingMatrixPrice( + fun build(): Matrix = + Matrix( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -6989,7 +6216,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingMatrixPrice = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -6998,7 +6225,11 @@ private constructor( currency() itemId() matrixConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -7032,7 +6263,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -7731,131 +6962,6 @@ private constructor( "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -8687,7 +7793,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Matrix && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -8697,16 +7803,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Matrix{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingMatrixWithAllocationPrice + class MatrixWithAllocation private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, private val matrixWithAllocationConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -8735,9 +7841,7 @@ private constructor( @ExcludeMissing matrixWithAllocationConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -8822,11 +7926,15 @@ private constructor( matrixWithAllocationConfig.getRequired("matrix_with_allocation_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -8953,16 +8061,6 @@ private constructor( fun _matrixWithAllocationConfig(): JsonField = matrixWithAllocationConfig - /** - * 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]. * @@ -9077,8 +8175,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingMatrixWithAllocationPrice]. + * Returns a mutable builder for constructing an instance of [MatrixWithAllocation]. * * The following fields are required: * ```java @@ -9086,14 +8183,13 @@ private constructor( * .currency() * .itemId() * .matrixWithAllocationConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingMatrixWithAllocationPrice]. */ + /** A builder for [MatrixWithAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -9101,7 +8197,7 @@ private constructor( private var itemId: JsonField? = null private var matrixWithAllocationConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -9117,29 +8213,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ) = apply { - cadence = newFloatingMatrixWithAllocationPrice.cadence - currency = newFloatingMatrixWithAllocationPrice.currency - itemId = newFloatingMatrixWithAllocationPrice.itemId - matrixWithAllocationConfig = - newFloatingMatrixWithAllocationPrice.matrixWithAllocationConfig - modelType = newFloatingMatrixWithAllocationPrice.modelType - name = newFloatingMatrixWithAllocationPrice.name - billableMetricId = newFloatingMatrixWithAllocationPrice.billableMetricId - billedInAdvance = newFloatingMatrixWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingMatrixWithAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingMatrixWithAllocationPrice.conversionRate - externalPriceId = newFloatingMatrixWithAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMatrixWithAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingMatrixWithAllocationPrice.metadata - additionalProperties = - newFloatingMatrixWithAllocationPrice.additionalProperties.toMutableMap() + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + currency = matrixWithAllocation.currency + itemId = matrixWithAllocation.itemId + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = matrixWithAllocation.invoicingCycleConfiguration + metadata = matrixWithAllocation.metadata + additionalProperties = matrixWithAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -9193,18 +8283,19 @@ private constructor( matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -9476,7 +8567,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingMatrixWithAllocationPrice]. + * Returns an immutable instance of [MatrixWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -9486,19 +8577,18 @@ private constructor( * .currency() * .itemId() * .matrixWithAllocationConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingMatrixWithAllocationPrice = - NewFloatingMatrixWithAllocationPrice( + fun build(): MatrixWithAllocation = + MatrixWithAllocation( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -9515,7 +8605,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingMatrixWithAllocationPrice = apply { + fun validate(): MatrixWithAllocation = apply { if (validated) { return@apply } @@ -9524,7 +8614,11 @@ private constructor( currency() itemId() matrixWithAllocationConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -9558,7 +8652,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -10306,131 +9400,6 @@ private constructor( "MatrixWithAllocationConfig{allocation=$allocation, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_ALLOCATION = of("matrix_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_ALLOCATION - } - - /** - * 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 { - MATRIX_WITH_ALLOCATION, - /** - * 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) { - MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -11262,7 +10231,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithAllocation && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -11272,15 +10241,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MatrixWithAllocation{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredPrice + class Tiered private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredConfig: JsonField, private val billableMetricId: JsonField, @@ -11306,9 +10275,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_config") @ExcludeMissing @@ -11388,11 +10355,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -11515,16 +10486,6 @@ private constructor( */ @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]. * @@ -11649,15 +10610,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredPrice]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` @@ -11665,13 +10624,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredPrice]. */ + /** A builder for [Tiered]. */ 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 modelType: JsonValue = JsonValue.from("tiered") private var name: JsonField? = null private var tieredConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -11688,24 +10647,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingTieredPrice: NewFloatingTieredPrice) = apply { - cadence = newFloatingTieredPrice.cadence - currency = newFloatingTieredPrice.currency - itemId = newFloatingTieredPrice.itemId - modelType = newFloatingTieredPrice.modelType - name = newFloatingTieredPrice.name - tieredConfig = newFloatingTieredPrice.tieredConfig - billableMetricId = newFloatingTieredPrice.billableMetricId - billedInAdvance = newFloatingTieredPrice.billedInAdvance - billingCycleConfiguration = newFloatingTieredPrice.billingCycleConfiguration - conversionRate = newFloatingTieredPrice.conversionRate - externalPriceId = newFloatingTieredPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingTieredPrice.invoicingCycleConfiguration - metadata = newFloatingTieredPrice.metadata - additionalProperties = - newFloatingTieredPrice.additionalProperties.toMutableMap() + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + currency = tiered.currency + itemId = tiered.itemId + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + metadata = tiered.metadata + additionalProperties = tiered.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -11744,18 +10702,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -12041,7 +11000,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredPrice]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -12050,19 +11009,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredPrice = - NewFloatingTieredPrice( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredConfig", tieredConfig), billableMetricId, @@ -12080,7 +11038,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredPrice = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } @@ -12088,7 +11046,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredConfig().validate() billableMetricId() @@ -12122,7 +11084,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -12291,131 +11253,6 @@ private constructor( 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 = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * 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, - /** - * 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 -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.TIERED - 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 TieredConfig private constructor( private val tiers: JsonField>, @@ -13697,7 +12534,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tiered && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -13707,15 +12544,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredBpsPrice + class TieredBps private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredBpsConfig: JsonField, private val billableMetricId: JsonField, @@ -13741,9 +12578,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_bps_config") @ExcludeMissing @@ -13823,11 +12658,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -13951,16 +12790,6 @@ private constructor( */ @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]. * @@ -14085,15 +12914,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredBpsPrice]. + * Returns a mutable builder for constructing an instance of [TieredBps]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` @@ -14101,13 +12928,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredBpsPrice]. */ + /** A builder for [TieredBps]. */ 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 modelType: JsonValue = JsonValue.from("tiered_bps") private var name: JsonField? = null private var tieredBpsConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -14124,25 +12951,23 @@ private constructor( 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 - externalPriceId = newFloatingTieredBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredBpsPrice.invoicingCycleConfiguration - metadata = newFloatingTieredBpsPrice.metadata - additionalProperties = - newFloatingTieredBpsPrice.additionalProperties.toMutableMap() + internal fun from(tieredBps: TieredBps) = apply { + cadence = tieredBps.cadence + currency = tieredBps.currency + itemId = tieredBps.itemId + modelType = tieredBps.modelType + name = tieredBps.name + tieredBpsConfig = tieredBps.tieredBpsConfig + billableMetricId = tieredBps.billableMetricId + billedInAdvance = tieredBps.billedInAdvance + billingCycleConfiguration = tieredBps.billingCycleConfiguration + conversionRate = tieredBps.conversionRate + externalPriceId = tieredBps.externalPriceId + fixedPriceQuantity = tieredBps.fixedPriceQuantity + invoiceGroupingKey = tieredBps.invoiceGroupingKey + invoicingCycleConfiguration = tieredBps.invoicingCycleConfiguration + metadata = tieredBps.metadata + additionalProperties = tieredBps.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -14181,18 +13006,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -14478,7 +13304,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredBpsPrice]. + * Returns an immutable instance of [TieredBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -14487,19 +13313,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredBpsPrice = - NewFloatingTieredBpsPrice( + fun build(): TieredBps = + TieredBps( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredBpsConfig", tieredBpsConfig), billableMetricId, @@ -14517,7 +13342,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredBpsPrice = apply { + fun validate(): TieredBps = apply { if (validated) { return@apply } @@ -14525,7 +13350,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredBpsConfig().validate() billableMetricId() @@ -14559,7 +13388,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -14728,131 +13557,6 @@ private constructor( 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() - } - class TieredBpsConfig private constructor( private val tiers: JsonField>, @@ -16182,7 +14886,7 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBps && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -16192,16 +14896,16 @@ private constructor( 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, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredBps{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingBpsPrice + class Bps private constructor( private val bpsConfig: JsonField, private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -16229,9 +14933,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -16315,11 +15017,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -16445,16 +15151,6 @@ private constructor( */ @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]. * @@ -16569,7 +15265,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewFloatingBpsPrice]. + * Returns a mutable builder for constructing an instance of [Bps]. * * The following fields are required: * ```java @@ -16577,21 +15273,20 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingBpsPrice]. */ + /** A builder for [Bps]. */ 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 modelType: JsonValue = JsonValue.from("bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -16607,23 +15302,23 @@ private constructor( 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 - externalPriceId = newFloatingBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBpsPrice.metadata - additionalProperties = newFloatingBpsPrice.additionalProperties.toMutableMap() + internal fun from(bps: Bps) = apply { + bpsConfig = bps.bpsConfig + cadence = bps.cadence + currency = bps.currency + itemId = bps.itemId + modelType = bps.modelType + name = bps.name + billableMetricId = bps.billableMetricId + billedInAdvance = bps.billedInAdvance + billingCycleConfiguration = bps.billingCycleConfiguration + conversionRate = bps.conversionRate + externalPriceId = bps.externalPriceId + fixedPriceQuantity = bps.fixedPriceQuantity + invoiceGroupingKey = bps.invoiceGroupingKey + invoicingCycleConfiguration = bps.invoicingCycleConfiguration + metadata = bps.metadata + additionalProperties = bps.additionalProperties.toMutableMap() } fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) @@ -16675,18 +15370,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -16958,7 +15654,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingBpsPrice]. + * Returns an immutable instance of [Bps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -16968,19 +15664,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingBpsPrice = - NewFloatingBpsPrice( + fun build(): Bps = + Bps( checkRequired("bpsConfig", bpsConfig), checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -16997,7 +15692,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingBpsPrice = apply { + fun validate(): Bps = apply { if (validated) { return@apply } @@ -17006,7 +15701,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -17040,7 +15739,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -17422,131 +16121,6 @@ private constructor( 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -18378,7 +16952,7 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bps && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -18388,16 +16962,16 @@ private constructor( 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, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Bps{bpsConfig=$bpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingBulkBpsPrice + class BulkBps private constructor( private val bulkBpsConfig: JsonField, private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -18425,9 +16999,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -18511,11 +17083,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -18641,16 +17217,6 @@ private constructor( */ @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]. * @@ -18765,8 +17331,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of [BulkBps]. * * The following fields are required: * ```java @@ -18774,21 +17339,20 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingBulkBpsPrice]. */ + /** A builder for [BulkBps]. */ class Builder internal constructor() { private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -18804,25 +17368,23 @@ 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 - externalPriceId = newFloatingBulkBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBulkBpsPrice.metadata - additionalProperties = - newFloatingBulkBpsPrice.additionalProperties.toMutableMap() + internal fun from(bulkBps: BulkBps) = apply { + bulkBpsConfig = bulkBps.bulkBpsConfig + cadence = bulkBps.cadence + currency = bulkBps.currency + itemId = bulkBps.itemId + modelType = bulkBps.modelType + name = bulkBps.name + billableMetricId = bulkBps.billableMetricId + billedInAdvance = bulkBps.billedInAdvance + billingCycleConfiguration = bulkBps.billingCycleConfiguration + conversionRate = bulkBps.conversionRate + externalPriceId = bulkBps.externalPriceId + fixedPriceQuantity = bulkBps.fixedPriceQuantity + invoiceGroupingKey = bulkBps.invoiceGroupingKey + invoicingCycleConfiguration = bulkBps.invoicingCycleConfiguration + metadata = bulkBps.metadata + additionalProperties = bulkBps.additionalProperties.toMutableMap() } fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = @@ -18875,18 +17437,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -19158,7 +17721,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingBulkBpsPrice]. + * Returns an immutable instance of [BulkBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -19168,19 +17731,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingBulkBpsPrice = - NewFloatingBulkBpsPrice( + fun build(): BulkBps = + BulkBps( checkRequired("bulkBpsConfig", bulkBpsConfig), checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -19197,7 +17759,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingBulkBpsPrice = apply { + fun validate(): BulkBps = apply { if (validated) { return@apply } @@ -19206,7 +17768,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -19240,7 +17806,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -19861,131 +18427,6 @@ private constructor( 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 BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -20817,7 +19258,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBps && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -20827,16 +19268,16 @@ private constructor( 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, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkBps{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingBulkPrice + class Bulk private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -20864,9 +19305,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -20950,11 +19389,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -21080,16 +19523,6 @@ private constructor( */ @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]. * @@ -21204,7 +19637,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewFloatingBulkPrice]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java @@ -21212,21 +19645,20 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingBulkPrice]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -21242,23 +19674,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingBulkPrice: NewFloatingBulkPrice) = apply { - bulkConfig = newFloatingBulkPrice.bulkConfig - cadence = newFloatingBulkPrice.cadence - currency = newFloatingBulkPrice.currency - itemId = newFloatingBulkPrice.itemId - modelType = newFloatingBulkPrice.modelType - name = newFloatingBulkPrice.name - billableMetricId = newFloatingBulkPrice.billableMetricId - billedInAdvance = newFloatingBulkPrice.billedInAdvance - billingCycleConfiguration = newFloatingBulkPrice.billingCycleConfiguration - conversionRate = newFloatingBulkPrice.conversionRate - externalPriceId = newFloatingBulkPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = newFloatingBulkPrice.invoicingCycleConfiguration - metadata = newFloatingBulkPrice.metadata - additionalProperties = newFloatingBulkPrice.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + currency = bulk.currency + itemId = bulk.itemId + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + metadata = bulk.metadata + additionalProperties = bulk.additionalProperties.toMutableMap() } fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) @@ -21310,18 +19742,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -21593,7 +20026,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingBulkPrice]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -21603,19 +20036,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingBulkPrice = - NewFloatingBulkPrice( + fun build(): Bulk = + Bulk( checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -21632,7 +20064,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingBulkPrice = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -21641,7 +20073,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -21675,7 +20111,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -22253,131 +20689,6 @@ private constructor( 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 BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -23209,7 +21520,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bulk && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -23219,15 +21530,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingThresholdTotalAmountPrice + class ThresholdTotalAmount private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val thresholdTotalAmountConfig: JsonField, private val billableMetricId: JsonField, @@ -23253,9 +21564,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("threshold_total_amount_config") @ExcludeMissing @@ -23336,11 +21645,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -23464,16 +21777,6 @@ private constructor( */ @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]. * @@ -23599,15 +21902,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingThresholdTotalAmountPrice]. + * Returns a mutable builder for constructing an instance of [ThresholdTotalAmount]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` @@ -23615,13 +21916,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingThresholdTotalAmountPrice]. */ + /** A builder for [ThresholdTotalAmount]. */ 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 modelType: JsonValue = JsonValue.from("threshold_total_amount") private var name: JsonField? = null private var thresholdTotalAmountConfig: JsonField? = null @@ -23639,29 +21940,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ) = apply { - cadence = newFloatingThresholdTotalAmountPrice.cadence - currency = newFloatingThresholdTotalAmountPrice.currency - itemId = newFloatingThresholdTotalAmountPrice.itemId - modelType = newFloatingThresholdTotalAmountPrice.modelType - name = newFloatingThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newFloatingThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newFloatingThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newFloatingThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newFloatingThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newFloatingThresholdTotalAmountPrice.conversionRate - externalPriceId = newFloatingThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = newFloatingThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingThresholdTotalAmountPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newFloatingThresholdTotalAmountPrice.metadata - additionalProperties = - newFloatingThresholdTotalAmountPrice.additionalProperties.toMutableMap() + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + currency = thresholdTotalAmount.currency + itemId = thresholdTotalAmount.itemId + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey + invoicingCycleConfiguration = thresholdTotalAmount.invoicingCycleConfiguration + metadata = thresholdTotalAmount.metadata + additionalProperties = thresholdTotalAmount.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -23700,18 +21995,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -23998,7 +22294,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingThresholdTotalAmountPrice]. + * Returns an immutable instance of [ThresholdTotalAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -24007,19 +22303,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingThresholdTotalAmountPrice = - NewFloatingThresholdTotalAmountPrice( + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), billableMetricId, @@ -24037,7 +22332,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingThresholdTotalAmountPrice = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } @@ -24045,7 +22340,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -24079,7 +22378,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("threshold_total_amount")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -24248,131 +22547,6 @@ private constructor( 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 THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * 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 { - THRESHOLD_TOTAL_AMOUNT, - /** - * 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) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - 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 ThresholdTotalAmountConfig @JsonCreator private constructor( @@ -25317,7 +23491,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmount && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -25327,15 +23501,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredPackagePrice + class TieredPackage private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredPackageConfig: JsonField, private val billableMetricId: JsonField, @@ -25361,9 +23535,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_package_config") @ExcludeMissing @@ -25443,11 +23615,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -25571,16 +23747,6 @@ private constructor( */ @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]. * @@ -25705,15 +23871,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [TieredPackage]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` @@ -25721,13 +23885,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredPackagePrice]. */ + /** A builder for [TieredPackage]. */ 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 modelType: JsonValue = JsonValue.from("tiered_package") private var name: JsonField? = null private var tieredPackageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -25744,28 +23908,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice) = - apply { - cadence = newFloatingTieredPackagePrice.cadence - currency = newFloatingTieredPackagePrice.currency - itemId = newFloatingTieredPackagePrice.itemId - modelType = newFloatingTieredPackagePrice.modelType - name = newFloatingTieredPackagePrice.name - tieredPackageConfig = newFloatingTieredPackagePrice.tieredPackageConfig - billableMetricId = newFloatingTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingTieredPackagePrice.conversionRate - externalPriceId = newFloatingTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingTieredPackagePrice.metadata - additionalProperties = - newFloatingTieredPackagePrice.additionalProperties.toMutableMap() - } + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + currency = tieredPackage.currency + itemId = tieredPackage.itemId + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + metadata = tieredPackage.metadata + additionalProperties = tieredPackage.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -25803,18 +23963,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -26101,7 +24262,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredPackagePrice]. + * Returns an immutable instance of [TieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -26110,19 +24271,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredPackagePrice = - NewFloatingTieredPackagePrice( + fun build(): TieredPackage = + TieredPackage( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredPackageConfig", tieredPackageConfig), billableMetricId, @@ -26140,7 +24300,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredPackagePrice = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } @@ -26148,7 +24308,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredPackageConfig().validate() billableMetricId() @@ -26182,7 +24346,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -26351,99 +24515,77 @@ private constructor( 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 { + class TieredPackageConfig + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - @JvmField val TIERED_PACKAGE = of("tiered_package") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } + fun toBuilder() = Builder().from(this) - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } + companion object { - /** - * 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_PACKAGE, /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. + * Returns a mutable builder for constructing an instance of + * [TieredPackageConfig]. */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - OrbInvalidDataException("Value is not a String") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig(additionalProperties.toImmutable()) + } + private var validated: Boolean = false - fun validate(): ModelType = apply { + fun validate(): TieredPackageConfig = apply { if (validated) { return@apply } - known() validated = true } @@ -26461,31 +24603,97 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @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 ModelType && value == other.value /* spotless:on */ + return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode() = value.hashCode() + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{additionalProperties=$additionalProperties}" } - class TieredPackageConfig - @JsonCreator + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + class BillingCycleConfiguration private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val duration: JsonField, + private val durationUnit: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + durationUnit: JsonField = JsonMissing.of(), + ) : this(duration, durationUnit, mutableMapOf()) + + /** + * The duration of the billing 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 duration(): Long = duration.getRequired("duration") + + /** + * The unit of billing period duration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [durationUnit]. + * + * Unlike [durationUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit + + @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) @@ -26493,227 +24701,58 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredPackageConfig]. + * [BillingCycleConfiguration]. + * + * The following fields are required: + * ```java + * .duration() + * .durationUnit() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredPackageConfig]. */ + /** A builder for [BillingCycleConfiguration]. */ class Builder internal constructor() { + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredPackageConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @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 TieredPackageConfig && 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() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or months. - */ - class BillingCycleConfiguration - private constructor( - private val duration: JsonField, - private val durationUnit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - durationUnit: JsonField = JsonMissing.of(), - ) : this(duration, durationUnit, mutableMapOf()) - - /** - * The duration of the billing 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 duration(): Long = duration.getRequired("duration") - - /** - * The unit of billing period duration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** - * Returns the raw JSON value of [durationUnit]. - * - * Unlike [durationUnit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BillingCycleConfiguration]. - * - * The following fields are required: - * ```java - * .duration() - * .durationUnit() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** - * Sets [Builder.durationUnit] to an arbitrary JSON value. - * - * You should usually call [Builder.durationUnit] with a well-typed - * [DurationUnit] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = + apply { + duration = billingCycleConfiguration.duration + durationUnit = billingCycleConfiguration.durationUnit + additionalProperties = + billingCycleConfiguration.additionalProperties.toMutableMap() + } + + /** The duration of the billing period. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** + * Sets [Builder.durationUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.durationUnit] with a well-typed + * [DurationUnit] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit } fun additionalProperties(additionalProperties: Map) = apply { @@ -27419,7 +25458,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackage && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -27429,16 +25468,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredPackage{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedTieredPrice + class GroupedTiered private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedTieredConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -27466,9 +25505,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -27553,11 +25590,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -27683,16 +25724,6 @@ private constructor( */ @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]. * @@ -27807,8 +25838,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedTieredPrice]. + * Returns a mutable builder for constructing an instance of [GroupedTiered]. * * The following fields are required: * ```java @@ -27816,21 +25846,20 @@ private constructor( * .currency() * .groupedTieredConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedTieredPrice]. */ + /** A builder for [GroupedTiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null private var groupedTieredConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -27846,28 +25875,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice) = - apply { - cadence = newFloatingGroupedTieredPrice.cadence - currency = newFloatingGroupedTieredPrice.currency - groupedTieredConfig = newFloatingGroupedTieredPrice.groupedTieredConfig - itemId = newFloatingGroupedTieredPrice.itemId - modelType = newFloatingGroupedTieredPrice.modelType - name = newFloatingGroupedTieredPrice.name - billableMetricId = newFloatingGroupedTieredPrice.billableMetricId - billedInAdvance = newFloatingGroupedTieredPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedTieredPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedTieredPrice.conversionRate - externalPriceId = newFloatingGroupedTieredPrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedTieredPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedTieredPrice.metadata - additionalProperties = - newFloatingGroupedTieredPrice.additionalProperties.toMutableMap() - } + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + currency = groupedTiered.currency + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + metadata = groupedTiered.metadata + additionalProperties = groupedTiered.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -27920,18 +25945,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -28203,7 +26229,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingGroupedTieredPrice]. + * Returns an immutable instance of [GroupedTiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -28213,19 +26239,18 @@ private constructor( * .currency() * .groupedTieredConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedTieredPrice = - NewFloatingGroupedTieredPrice( + fun build(): GroupedTiered = + GroupedTiered( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("groupedTieredConfig", groupedTieredConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -28242,7 +26267,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedTieredPrice = apply { + fun validate(): GroupedTiered = apply { if (validated) { return@apply } @@ -28251,7 +26276,11 @@ private constructor( currency() groupedTieredConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -28285,7 +26314,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -28565,131 +26594,6 @@ private constructor( "GroupedTieredConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED = of("grouped_tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED - } - - /** - * 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 { - GROUPED_TIERED, - /** - * 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) { - GROUPED_TIERED -> Value.GROUPED_TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED -> Known.GROUPED_TIERED - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -29521,7 +27425,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTiered && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -29531,16 +27435,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedTiered{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingMaxGroupTieredPackagePrice + class MaxGroupTieredPackage private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, private val maxGroupTieredPackageConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -29569,9 +27473,7 @@ private constructor( @ExcludeMissing maxGroupTieredPackageConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -29656,11 +27558,15 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_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). + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -29787,16 +27693,6 @@ private constructor( fun _maxGroupTieredPackageConfig(): JsonField = maxGroupTieredPackageConfig - /** - * 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]. * @@ -29912,7 +27808,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingMaxGroupTieredPackagePrice]. + * [MaxGroupTieredPackage]. * * The following fields are required: * ```java @@ -29920,14 +27816,13 @@ private constructor( * .currency() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingMaxGroupTieredPackagePrice]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -29935,7 +27830,7 @@ private constructor( private var itemId: JsonField? = null private var maxGroupTieredPackageConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -29951,29 +27846,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ) = apply { - cadence = newFloatingMaxGroupTieredPackagePrice.cadence - currency = newFloatingMaxGroupTieredPackagePrice.currency - itemId = newFloatingMaxGroupTieredPackagePrice.itemId - maxGroupTieredPackageConfig = - newFloatingMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newFloatingMaxGroupTieredPackagePrice.modelType - name = newFloatingMaxGroupTieredPackagePrice.name - billableMetricId = newFloatingMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingMaxGroupTieredPackagePrice.conversionRate - externalPriceId = newFloatingMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMaxGroupTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingMaxGroupTieredPackagePrice.metadata - additionalProperties = - newFloatingMaxGroupTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + currency = maxGroupTieredPackage.currency + itemId = maxGroupTieredPackage.itemId + maxGroupTieredPackageConfig = maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = maxGroupTieredPackage.invoicingCycleConfiguration + metadata = maxGroupTieredPackage.metadata + additionalProperties = maxGroupTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -30027,18 +27916,19 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -30310,7 +28200,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingMaxGroupTieredPackagePrice]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -30320,19 +28210,18 @@ private constructor( * .currency() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingMaxGroupTieredPackagePrice = - NewFloatingMaxGroupTieredPackagePrice( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), checkRequired("maxGroupTieredPackageConfig", maxGroupTieredPackageConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -30349,7 +28238,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingMaxGroupTieredPackagePrice = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -30358,7 +28247,11 @@ private constructor( currency() itemId() maxGroupTieredPackageConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -30392,7 +28285,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -30673,131 +28568,6 @@ private constructor( "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * 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 { - MAX_GROUP_TIERED_PACKAGE, - /** - * 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) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -31629,7 +29399,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MaxGroupTieredPackage && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -31639,15 +29409,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredWithMinimumPrice + class TieredWithMinimum private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithMinimumConfig: JsonField, private val billableMetricId: JsonField, @@ -31673,9 +29443,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_minimum_config") @ExcludeMissing @@ -31755,11 +29523,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -31883,16 +29655,6 @@ private constructor( */ @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]. * @@ -32018,15 +29780,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredWithMinimumPrice]. + * Returns a mutable builder for constructing an instance of [TieredWithMinimum]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` @@ -32034,13 +29794,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredWithMinimumPrice]. */ + /** A builder for [TieredWithMinimum]. */ 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 modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var tieredWithMinimumConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -32057,29 +29817,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ) = apply { - cadence = newFloatingTieredWithMinimumPrice.cadence - currency = newFloatingTieredWithMinimumPrice.currency - itemId = newFloatingTieredWithMinimumPrice.itemId - modelType = newFloatingTieredWithMinimumPrice.modelType - name = newFloatingTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newFloatingTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newFloatingTieredWithMinimumPrice.billableMetricId - billedInAdvance = newFloatingTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingTieredWithMinimumPrice.conversionRate - externalPriceId = newFloatingTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingTieredWithMinimumPrice.metadata - additionalProperties = - newFloatingTieredWithMinimumPrice.additionalProperties.toMutableMap() + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + currency = tieredWithMinimum.currency + itemId = tieredWithMinimum.itemId + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + metadata = tieredWithMinimum.metadata + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -32118,18 +29872,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -32415,7 +30170,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredWithMinimumPrice]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -32424,19 +30179,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredWithMinimumPrice = - NewFloatingTieredWithMinimumPrice( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), billableMetricId, @@ -32454,7 +30208,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredWithMinimumPrice = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } @@ -32462,7 +30216,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithMinimumConfig().validate() billableMetricId() @@ -32496,7 +30254,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -32665,131 +30423,6 @@ private constructor( 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_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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 TieredWithMinimumConfig @JsonCreator private constructor( @@ -33733,7 +31366,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithMinimum && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -33743,15 +31376,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredWithMinimum{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingPackageWithAllocationPrice + class PackageWithAllocation private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageWithAllocationConfig: JsonField, private val billableMetricId: JsonField, @@ -33777,9 +31410,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("package_with_allocation_config") @ExcludeMissing @@ -33860,11 +31491,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -33988,16 +31623,6 @@ private constructor( */ @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]. * @@ -34124,14 +31749,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingPackageWithAllocationPrice]. + * [PackageWithAllocation]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` @@ -34139,13 +31763,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingPackageWithAllocationPrice]. */ + /** A builder for [PackageWithAllocation]. */ 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 modelType: JsonValue = JsonValue.from("package_with_allocation") private var name: JsonField? = null private var packageWithAllocationConfig: JsonField? = null @@ -34163,29 +31787,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ) = apply { - cadence = newFloatingPackageWithAllocationPrice.cadence - currency = newFloatingPackageWithAllocationPrice.currency - itemId = newFloatingPackageWithAllocationPrice.itemId - modelType = newFloatingPackageWithAllocationPrice.modelType - name = newFloatingPackageWithAllocationPrice.name - packageWithAllocationConfig = - newFloatingPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = newFloatingPackageWithAllocationPrice.billableMetricId - billedInAdvance = newFloatingPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingPackageWithAllocationPrice.conversionRate - externalPriceId = newFloatingPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingPackageWithAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingPackageWithAllocationPrice.metadata - additionalProperties = - newFloatingPackageWithAllocationPrice.additionalProperties.toMutableMap() + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + currency = packageWithAllocation.currency + itemId = packageWithAllocation.itemId + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name + packageWithAllocationConfig = packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey + invoicingCycleConfiguration = packageWithAllocation.invoicingCycleConfiguration + metadata = packageWithAllocation.metadata + additionalProperties = packageWithAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -34224,18 +31842,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -34522,7 +32141,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingPackageWithAllocationPrice]. + * Returns an immutable instance of [PackageWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -34531,19 +32150,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingPackageWithAllocationPrice = - NewFloatingPackageWithAllocationPrice( + fun build(): PackageWithAllocation = + PackageWithAllocation( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageWithAllocationConfig", packageWithAllocationConfig), billableMetricId, @@ -34561,7 +32179,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingPackageWithAllocationPrice = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } @@ -34569,7 +32187,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageWithAllocationConfig().validate() billableMetricId() @@ -34603,7 +32225,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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 (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -34772,131 +32396,6 @@ private constructor( 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 PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * 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 { - PACKAGE_WITH_ALLOCATION, - /** - * 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) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - 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 PackageWithAllocationConfig @JsonCreator private constructor( @@ -35841,7 +33340,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocation && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -35851,15 +33350,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "PackageWithAllocation{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredPackageWithMinimumPrice + class TieredPackageWithMinimum private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredPackageWithMinimumConfig: JsonField, private val billableMetricId: JsonField, @@ -35885,9 +33384,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_package_with_minimum_config") @ExcludeMissing @@ -35968,11 +33465,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -36096,16 +33597,6 @@ private constructor( */ @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]. * @@ -36232,14 +33723,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredPackageWithMinimumPrice]. + * [TieredPackageWithMinimum]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredPackageWithMinimumConfig() * ``` @@ -36247,13 +33737,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredPackageWithMinimumPrice]. */ + /** A builder for [TieredPackageWithMinimum]. */ 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 modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") private var name: JsonField? = null private var tieredPackageWithMinimumConfig: JsonField? = @@ -36272,30 +33762,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingTieredPackageWithMinimumPrice: - NewFloatingTieredPackageWithMinimumPrice - ) = apply { - cadence = newFloatingTieredPackageWithMinimumPrice.cadence - currency = newFloatingTieredPackageWithMinimumPrice.currency - itemId = newFloatingTieredPackageWithMinimumPrice.itemId - modelType = newFloatingTieredPackageWithMinimumPrice.modelType - name = newFloatingTieredPackageWithMinimumPrice.name + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + currency = tieredPackageWithMinimum.currency + itemId = tieredPackageWithMinimum.itemId + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name tieredPackageWithMinimumConfig = - newFloatingTieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig - billableMetricId = newFloatingTieredPackageWithMinimumPrice.billableMetricId - billedInAdvance = newFloatingTieredPackageWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredPackageWithMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingTieredPackageWithMinimumPrice.conversionRate - externalPriceId = newFloatingTieredPackageWithMinimumPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPackageWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPackageWithMinimumPrice.invoiceGroupingKey + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance + billingCycleConfiguration = tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingTieredPackageWithMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingTieredPackageWithMinimumPrice.metadata + tieredPackageWithMinimum.invoicingCycleConfiguration + metadata = tieredPackageWithMinimum.metadata additionalProperties = - newFloatingTieredPackageWithMinimumPrice.additionalProperties.toMutableMap() + tieredPackageWithMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -36334,18 +33820,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -36632,7 +34119,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredPackageWithMinimumPrice]. + * Returns an immutable instance of [TieredPackageWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -36641,19 +34128,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredPackageWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredPackageWithMinimumPrice = - NewFloatingTieredPackageWithMinimumPrice( + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "tieredPackageWithMinimumConfig", @@ -36674,7 +34160,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredPackageWithMinimumPrice = apply { + fun validate(): TieredPackageWithMinimum = apply { if (validated) { return@apply } @@ -36682,7 +34168,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredPackageWithMinimumConfig().validate() billableMetricId() @@ -36716,7 +34206,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -36885,131 +34377,6 @@ private constructor( 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_PACKAGE_WITH_MINIMUM = of("tiered_package_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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 TieredPackageWithMinimumConfig @JsonCreator private constructor( @@ -37955,7 +35322,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackageWithMinimum && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -37965,15 +35332,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimum{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingUnitWithPercentPrice + class UnitWithPercent private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithPercentConfig: JsonField, private val billableMetricId: JsonField, @@ -37999,9 +35366,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_percent_config") @ExcludeMissing @@ -38081,11 +35446,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -38209,16 +35578,6 @@ private constructor( */ @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]. * @@ -38343,15 +35702,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingUnitWithPercentPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` @@ -38359,13 +35716,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingUnitWithPercentPrice]. */ + /** A builder for [UnitWithPercent]. */ 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 modelType: JsonValue = JsonValue.from("unit_with_percent") private var name: JsonField? = null private var unitWithPercentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -38382,28 +35739,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ) = apply { - cadence = newFloatingUnitWithPercentPrice.cadence - currency = newFloatingUnitWithPercentPrice.currency - itemId = newFloatingUnitWithPercentPrice.itemId - modelType = newFloatingUnitWithPercentPrice.modelType - name = newFloatingUnitWithPercentPrice.name - unitWithPercentConfig = newFloatingUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newFloatingUnitWithPercentPrice.billableMetricId - billedInAdvance = newFloatingUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newFloatingUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newFloatingUnitWithPercentPrice.conversionRate - externalPriceId = newFloatingUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newFloatingUnitWithPercentPrice.metadata - additionalProperties = - newFloatingUnitWithPercentPrice.additionalProperties.toMutableMap() + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + currency = unitWithPercent.currency + itemId = unitWithPercent.itemId + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + metadata = unitWithPercent.metadata + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -38442,18 +35794,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -38740,7 +36093,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingUnitWithPercentPrice]. + * Returns an immutable instance of [UnitWithPercent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -38749,19 +36102,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingUnitWithPercentPrice = - NewFloatingUnitWithPercentPrice( + fun build(): UnitWithPercent = + UnitWithPercent( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithPercentConfig", unitWithPercentConfig), billableMetricId, @@ -38779,7 +36131,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingUnitWithPercentPrice = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } @@ -38787,7 +36139,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithPercentConfig().validate() billableMetricId() @@ -38821,7 +36177,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -38990,131 +36346,6 @@ private constructor( 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 UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * 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 { - UNIT_WITH_PERCENT, - /** - * 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) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - 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 UnitWithPercentConfig @JsonCreator private constructor( @@ -40058,7 +37289,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercent && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -40068,15 +37299,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "UnitWithPercent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredWithProrationPrice + class TieredWithProration private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -40102,9 +37333,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_proration_config") @ExcludeMissing @@ -40184,11 +37413,15 @@ private constructor( 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). + * 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). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -40312,16 +37545,6 @@ private constructor( */ @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]. * @@ -40447,15 +37670,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredWithProrationPrice]. + * Returns a mutable builder for constructing an instance of [TieredWithProration]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` @@ -40463,13 +37684,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredWithProrationPrice]. */ + /** A builder for [TieredWithProration]. */ 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 modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null private var tieredWithProrationConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -40486,29 +37707,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ) = apply { - cadence = newFloatingTieredWithProrationPrice.cadence - currency = newFloatingTieredWithProrationPrice.currency - itemId = newFloatingTieredWithProrationPrice.itemId - modelType = newFloatingTieredWithProrationPrice.modelType - name = newFloatingTieredWithProrationPrice.name - tieredWithProrationConfig = - newFloatingTieredWithProrationPrice.tieredWithProrationConfig - billableMetricId = newFloatingTieredWithProrationPrice.billableMetricId - billedInAdvance = newFloatingTieredWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingTieredWithProrationPrice.conversionRate - externalPriceId = newFloatingTieredWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingTieredWithProrationPrice.metadata - additionalProperties = - newFloatingTieredWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + currency = tieredWithProration.currency + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + additionalProperties = tieredWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -40547,18 +37762,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -40845,7 +38061,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredWithProrationPrice]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -40854,19 +38070,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredWithProrationPrice = - NewFloatingTieredWithProrationPrice( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, @@ -40884,7 +38099,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredWithProrationPrice = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } @@ -40892,7 +38107,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithProrationConfig().validate() billableMetricId() @@ -40926,7 +38145,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -41095,131 +38314,6 @@ private constructor( 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( @@ -42164,7 +39258,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithProration && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -42174,15 +39268,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingUnitWithProrationPrice + class UnitWithProration private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -42208,9 +39302,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_proration_config") @ExcludeMissing @@ -42290,11 +39382,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -42418,16 +39514,6 @@ private constructor( */ @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]. * @@ -42553,15 +39639,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingUnitWithProrationPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithProration]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` @@ -42569,13 +39653,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingUnitWithProrationPrice]. */ + /** A builder for [UnitWithProration]. */ 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 modelType: JsonValue = JsonValue.from("unit_with_proration") private var name: JsonField? = null private var unitWithProrationConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -42592,29 +39676,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ) = apply { - cadence = newFloatingUnitWithProrationPrice.cadence - currency = newFloatingUnitWithProrationPrice.currency - itemId = newFloatingUnitWithProrationPrice.itemId - modelType = newFloatingUnitWithProrationPrice.modelType - name = newFloatingUnitWithProrationPrice.name - unitWithProrationConfig = - newFloatingUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newFloatingUnitWithProrationPrice.billableMetricId - billedInAdvance = newFloatingUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingUnitWithProrationPrice.conversionRate - externalPriceId = newFloatingUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingUnitWithProrationPrice.metadata - additionalProperties = - newFloatingUnitWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + currency = unitWithProration.currency + itemId = unitWithProration.itemId + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + metadata = unitWithProration.metadata + additionalProperties = unitWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -42653,18 +39731,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -42950,7 +40029,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingUnitWithProrationPrice]. + * Returns an immutable instance of [UnitWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -42959,19 +40038,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingUnitWithProrationPrice = - NewFloatingUnitWithProrationPrice( + fun build(): UnitWithProration = + UnitWithProration( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithProrationConfig", unitWithProrationConfig), billableMetricId, @@ -42989,7 +40067,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingUnitWithProrationPrice = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } @@ -42997,7 +40075,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithProrationConfig().validate() billableMetricId() @@ -43031,7 +40113,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_proration")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -43200,131 +40282,6 @@ private constructor( 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 UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_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 { - UNIT_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) { - UNIT_WITH_PRORATION -> Value.UNIT_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) { - UNIT_WITH_PRORATION -> Known.UNIT_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 UnitWithProrationConfig @JsonCreator private constructor( @@ -44268,7 +41225,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProration && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -44278,16 +41235,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "UnitWithProration{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedAllocationPrice + class GroupedAllocation private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedAllocationConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -44315,9 +41272,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -44402,11 +41357,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -44533,16 +41492,6 @@ private constructor( */ @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]. * @@ -44657,8 +41606,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedAllocationPrice]. + * Returns a mutable builder for constructing an instance of [GroupedAllocation]. * * The following fields are required: * ```java @@ -44666,21 +41614,20 @@ private constructor( * .currency() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedAllocationPrice]. */ + /** A builder for [GroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null private var groupedAllocationConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -44696,29 +41643,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ) = apply { - cadence = newFloatingGroupedAllocationPrice.cadence - currency = newFloatingGroupedAllocationPrice.currency - groupedAllocationConfig = - newFloatingGroupedAllocationPrice.groupedAllocationConfig - itemId = newFloatingGroupedAllocationPrice.itemId - modelType = newFloatingGroupedAllocationPrice.modelType - name = newFloatingGroupedAllocationPrice.name - billableMetricId = newFloatingGroupedAllocationPrice.billableMetricId - billedInAdvance = newFloatingGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedAllocationPrice.conversionRate - externalPriceId = newFloatingGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedAllocationPrice.metadata - additionalProperties = - newFloatingGroupedAllocationPrice.additionalProperties.toMutableMap() + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + currency = groupedAllocation.currency + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + metadata = groupedAllocation.metadata + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -44771,18 +41712,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -45054,7 +41996,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingGroupedAllocationPrice]. + * Returns an immutable instance of [GroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -45064,19 +42006,18 @@ private constructor( * .currency() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedAllocationPrice = - NewFloatingGroupedAllocationPrice( + fun build(): GroupedAllocation = + GroupedAllocation( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("groupedAllocationConfig", groupedAllocationConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -45093,7 +42034,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedAllocationPrice = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -45102,7 +42043,11 @@ private constructor( currency() groupedAllocationConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -45136,7 +42081,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -45416,131 +42361,6 @@ private constructor( "GroupedAllocationConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * 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 { - GROUPED_ALLOCATION, - /** - * 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) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -46372,7 +43192,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocation && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -46382,17 +43202,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedAllocation{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedWithProratedMinimumPrice + class GroupedWithProratedMinimum private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedWithProratedMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -46421,9 +43241,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -46508,11 +43326,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -46639,16 +43461,6 @@ private constructor( */ @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]. * @@ -46764,7 +43576,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedWithProratedMinimumPrice]. + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```java @@ -46772,14 +43584,13 @@ private constructor( * .currency() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedWithProratedMinimumPrice]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -46788,7 +43599,7 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_with_prorated_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -46804,33 +43615,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice - ) = apply { - cadence = newFloatingGroupedWithProratedMinimumPrice.cadence - currency = newFloatingGroupedWithProratedMinimumPrice.currency + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = apply { + cadence = groupedWithProratedMinimum.cadence + currency = groupedWithProratedMinimum.currency groupedWithProratedMinimumConfig = - newFloatingGroupedWithProratedMinimumPrice.groupedWithProratedMinimumConfig - itemId = newFloatingGroupedWithProratedMinimumPrice.itemId - modelType = newFloatingGroupedWithProratedMinimumPrice.modelType - name = newFloatingGroupedWithProratedMinimumPrice.name - billableMetricId = newFloatingGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = newFloatingGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedWithProratedMinimumPrice.conversionRate - externalPriceId = newFloatingGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingGroupedWithProratedMinimumPrice.invoiceGroupingKey + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingGroupedWithProratedMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedWithProratedMinimumPrice.metadata + groupedWithProratedMinimum.invoicingCycleConfiguration + metadata = groupedWithProratedMinimum.metadata additionalProperties = - newFloatingGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() + groupedWithProratedMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -46886,18 +43690,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -47169,7 +43974,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingGroupedWithProratedMinimumPrice]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -47179,14 +43984,13 @@ private constructor( * .currency() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedWithProratedMinimumPrice = - NewFloatingGroupedWithProratedMinimumPrice( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired( @@ -47194,7 +43998,7 @@ private constructor( groupedWithProratedMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -47211,7 +44015,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedWithProratedMinimumPrice = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -47220,7 +44024,11 @@ private constructor( currency() groupedWithProratedMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -47254,7 +44062,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -47536,132 +44346,6 @@ private constructor( "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -48493,7 +45177,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimum && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -48503,16 +45187,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedWithMeteredMinimumPrice + class GroupedWithMeteredMinimum private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -48541,9 +45225,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -48628,11 +45310,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -48759,16 +45445,6 @@ private constructor( */ @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]. * @@ -48884,7 +45560,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedWithMeteredMinimumPrice]. + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```java @@ -48892,14 +45568,13 @@ private constructor( * .currency() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedWithMeteredMinimumPrice]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -48908,7 +45583,7 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_with_metered_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -48924,33 +45599,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingGroupedWithMeteredMinimumPrice: - NewFloatingGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newFloatingGroupedWithMeteredMinimumPrice.cadence - currency = newFloatingGroupedWithMeteredMinimumPrice.currency + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = apply { + cadence = groupedWithMeteredMinimum.cadence + currency = groupedWithMeteredMinimum.currency groupedWithMeteredMinimumConfig = - newFloatingGroupedWithMeteredMinimumPrice.groupedWithMeteredMinimumConfig - itemId = newFloatingGroupedWithMeteredMinimumPrice.itemId - modelType = newFloatingGroupedWithMeteredMinimumPrice.modelType - name = newFloatingGroupedWithMeteredMinimumPrice.name - billableMetricId = newFloatingGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = newFloatingGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedWithMeteredMinimumPrice.conversionRate - externalPriceId = newFloatingGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingGroupedWithMeteredMinimumPrice.invoiceGroupingKey + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedWithMeteredMinimumPrice.metadata + groupedWithMeteredMinimum.invoicingCycleConfiguration + metadata = groupedWithMeteredMinimum.metadata additionalProperties = - newFloatingGroupedWithMeteredMinimumPrice.additionalProperties - .toMutableMap() + groupedWithMeteredMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -49004,18 +45672,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -49287,7 +45956,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingGroupedWithMeteredMinimumPrice]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -49297,14 +45966,13 @@ private constructor( * .currency() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedWithMeteredMinimumPrice = - NewFloatingGroupedWithMeteredMinimumPrice( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired( @@ -49312,7 +45980,7 @@ private constructor( groupedWithMeteredMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -49329,7 +45997,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedWithMeteredMinimumPrice = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -49338,7 +46006,11 @@ private constructor( currency() groupedWithMeteredMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -49372,7 +46044,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -49654,131 +46328,6 @@ private constructor( "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -50610,7 +47159,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimum && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -50620,16 +47169,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingMatrixWithDisplayNamePrice + class MatrixWithDisplayName private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, private val matrixWithDisplayNameConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -50658,9 +47207,7 @@ private constructor( @ExcludeMissing matrixWithDisplayNameConfig: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -50745,11 +47292,15 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -50876,16 +47427,6 @@ private constructor( fun _matrixWithDisplayNameConfig(): JsonField = matrixWithDisplayNameConfig - /** - * 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]. * @@ -51001,7 +47542,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingMatrixWithDisplayNamePrice]. + * [MatrixWithDisplayName]. * * The following fields are required: * ```java @@ -51009,14 +47550,13 @@ private constructor( * .currency() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingMatrixWithDisplayNamePrice]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -51024,7 +47564,7 @@ private constructor( private var itemId: JsonField? = null private var matrixWithDisplayNameConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -51040,29 +47580,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ) = apply { - cadence = newFloatingMatrixWithDisplayNamePrice.cadence - currency = newFloatingMatrixWithDisplayNamePrice.currency - itemId = newFloatingMatrixWithDisplayNamePrice.itemId - matrixWithDisplayNameConfig = - newFloatingMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newFloatingMatrixWithDisplayNamePrice.modelType - name = newFloatingMatrixWithDisplayNamePrice.name - billableMetricId = newFloatingMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newFloatingMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newFloatingMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newFloatingMatrixWithDisplayNamePrice.conversionRate - externalPriceId = newFloatingMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newFloatingMatrixWithDisplayNamePrice.metadata - additionalProperties = - newFloatingMatrixWithDisplayNamePrice.additionalProperties.toMutableMap() + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + currency = matrixWithDisplayName.currency + itemId = matrixWithDisplayName.itemId + matrixWithDisplayNameConfig = matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey + invoicingCycleConfiguration = matrixWithDisplayName.invoicingCycleConfiguration + metadata = matrixWithDisplayName.metadata + additionalProperties = matrixWithDisplayName.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -51116,18 +47650,19 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -51399,7 +47934,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingMatrixWithDisplayNamePrice]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -51409,19 +47944,18 @@ private constructor( * .currency() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingMatrixWithDisplayNamePrice = - NewFloatingMatrixWithDisplayNamePrice( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), checkRequired("matrixWithDisplayNameConfig", matrixWithDisplayNameConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -51438,7 +47972,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingMatrixWithDisplayNamePrice = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -51447,7 +47981,11 @@ private constructor( currency() itemId() matrixWithDisplayNameConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -51481,7 +48019,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -51762,131 +48302,6 @@ private constructor( "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * 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 { - MATRIX_WITH_DISPLAY_NAME, - /** - * 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) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -52718,7 +49133,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayName && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -52728,16 +49143,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingBulkWithProrationPrice + class BulkWithProration private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -52765,9 +49180,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -52852,11 +49265,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -52983,16 +49400,6 @@ private constructor( */ @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]. * @@ -53107,8 +49514,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingBulkWithProrationPrice]. + * Returns a mutable builder for constructing an instance of [BulkWithProration]. * * The following fields are required: * ```java @@ -53116,21 +49522,20 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingBulkWithProrationPrice]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -53146,29 +49551,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newFloatingBulkWithProrationPrice.bulkWithProrationConfig - cadence = newFloatingBulkWithProrationPrice.cadence - currency = newFloatingBulkWithProrationPrice.currency - itemId = newFloatingBulkWithProrationPrice.itemId - modelType = newFloatingBulkWithProrationPrice.modelType - name = newFloatingBulkWithProrationPrice.name - billableMetricId = newFloatingBulkWithProrationPrice.billableMetricId - billedInAdvance = newFloatingBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingBulkWithProrationPrice.conversionRate - externalPriceId = newFloatingBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingBulkWithProrationPrice.metadata - additionalProperties = - newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + currency = bulkWithProration.currency + itemId = bulkWithProration.itemId + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + metadata = bulkWithProration.metadata + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = @@ -53221,18 +49620,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -53504,7 +49904,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingBulkWithProrationPrice]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -53514,19 +49914,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingBulkWithProrationPrice = - NewFloatingBulkWithProrationPrice( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -53543,7 +49942,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingBulkWithProrationPrice = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -53552,7 +49951,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -53586,7 +49989,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_with_proration")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -53866,131 +50269,6 @@ private constructor( 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 BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_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 { - BULK_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) { - BULK_WITH_PRORATION -> Value.BULK_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) { - BULK_WITH_PRORATION -> Known.BULK_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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -54822,7 +51100,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkWithProration && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -54832,16 +51110,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedTieredPackagePrice + class GroupedTieredPackage private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedTieredPackageConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -54870,9 +51148,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -54957,11 +51233,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -55088,16 +51368,6 @@ private constructor( */ @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]. * @@ -55212,8 +51482,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [GroupedTieredPackage]. * * The following fields are required: * ```java @@ -55221,14 +51490,13 @@ private constructor( * .currency() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedTieredPackagePrice]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -55236,7 +51504,7 @@ private constructor( private var groupedTieredPackageConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -55252,29 +51520,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ) = apply { - cadence = newFloatingGroupedTieredPackagePrice.cadence - currency = newFloatingGroupedTieredPackagePrice.currency - groupedTieredPackageConfig = - newFloatingGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newFloatingGroupedTieredPackagePrice.itemId - modelType = newFloatingGroupedTieredPackagePrice.modelType - name = newFloatingGroupedTieredPackagePrice.name - billableMetricId = newFloatingGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingGroupedTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingGroupedTieredPackagePrice.conversionRate - externalPriceId = newFloatingGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingGroupedTieredPackagePrice.metadata - additionalProperties = - newFloatingGroupedTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + currency = groupedTieredPackage.currency + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = groupedTieredPackage.invoicingCycleConfiguration + metadata = groupedTieredPackage.metadata + additionalProperties = groupedTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -55328,18 +51590,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -55611,7 +51874,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingGroupedTieredPackagePrice]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -55621,19 +51884,18 @@ private constructor( * .currency() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedTieredPackagePrice = - NewFloatingGroupedTieredPackagePrice( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -55650,7 +51912,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedTieredPackagePrice = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -55659,7 +51921,11 @@ private constructor( currency() groupedTieredPackageConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -55693,7 +51959,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -55974,131 +52240,6 @@ private constructor( "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * 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 { - GROUPED_TIERED_PACKAGE, - /** - * 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) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -56930,7 +53071,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPackage && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -56940,15 +53081,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingScalableMatrixWithUnitPricingPrice + class ScalableMatrixWithUnitPricing private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithUnitPricingConfig: JsonField, @@ -56975,9 +53116,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("scalable_matrix_with_unit_pricing_config") @ExcludeMissing @@ -57059,11 +53198,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -57189,16 +53332,6 @@ private constructor( */ @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]. * @@ -57325,14 +53458,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingScalableMatrixWithUnitPricingPrice]. + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` @@ -57340,13 +53472,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ 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 modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var scalableMatrixWithUnitPricingConfig: JsonField? = @@ -57365,36 +53498,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice - ) = apply { - cadence = newFloatingScalableMatrixWithUnitPricingPrice.cadence - currency = newFloatingScalableMatrixWithUnitPricingPrice.currency - itemId = newFloatingScalableMatrixWithUnitPricingPrice.itemId - modelType = newFloatingScalableMatrixWithUnitPricingPrice.modelType - name = newFloatingScalableMatrixWithUnitPricingPrice.name - scalableMatrixWithUnitPricingConfig = - newFloatingScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = - newFloatingScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = newFloatingScalableMatrixWithUnitPricingPrice.billedInAdvance - billingCycleConfiguration = - newFloatingScalableMatrixWithUnitPricingPrice.billingCycleConfiguration - conversionRate = newFloatingScalableMatrixWithUnitPricingPrice.conversionRate - externalPriceId = newFloatingScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newFloatingScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingScalableMatrixWithUnitPricingPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingScalableMatrixWithUnitPricingPrice.invoicingCycleConfiguration - metadata = newFloatingScalableMatrixWithUnitPricingPrice.metadata - additionalProperties = - newFloatingScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() - } + internal fun from(scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing) = + apply { + cadence = scalableMatrixWithUnitPricing.cadence + currency = scalableMatrixWithUnitPricing.currency + itemId = scalableMatrixWithUnitPricing.itemId + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name + scalableMatrixWithUnitPricingConfig = + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance + billingCycleConfiguration = + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey + invoicingCycleConfiguration = + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithUnitPricing.metadata + additionalProperties = + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -57432,18 +53558,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -57736,7 +53863,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingScalableMatrixWithUnitPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -57745,19 +53872,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingScalableMatrixWithUnitPricingPrice = - NewFloatingScalableMatrixWithUnitPricingPrice( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithUnitPricingConfig", @@ -57778,7 +53904,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingScalableMatrixWithUnitPricingPrice = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } @@ -57786,7 +53912,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -57820,7 +53950,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -57989,132 +54121,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_UNIT_PRICING = of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - 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 ScalableMatrixWithUnitPricingConfig @JsonCreator private constructor( @@ -59060,7 +55066,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithUnitPricing && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -59070,15 +55076,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingScalableMatrixWithTieredPricingPrice + class ScalableMatrixWithTieredPricing private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithTieredPricingConfig: JsonField, @@ -59105,9 +55111,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("scalable_matrix_with_tiered_pricing_config") @ExcludeMissing @@ -59189,11 +55193,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -59319,16 +55327,6 @@ private constructor( */ @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]. * @@ -59456,14 +55454,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingScalableMatrixWithTieredPricingPrice]. + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` @@ -59471,13 +55468,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingScalableMatrixWithTieredPricingPrice]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ 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 modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var scalableMatrixWithTieredPricingConfig: JsonField? = @@ -59497,36 +55495,28 @@ private constructor( @JvmSynthetic internal fun from( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = apply { - cadence = newFloatingScalableMatrixWithTieredPricingPrice.cadence - currency = newFloatingScalableMatrixWithTieredPricingPrice.currency - itemId = newFloatingScalableMatrixWithTieredPricingPrice.itemId - modelType = newFloatingScalableMatrixWithTieredPricingPrice.modelType - name = newFloatingScalableMatrixWithTieredPricingPrice.name + cadence = scalableMatrixWithTieredPricing.cadence + currency = scalableMatrixWithTieredPricing.currency + itemId = scalableMatrixWithTieredPricing.itemId + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name scalableMatrixWithTieredPricingConfig = - newFloatingScalableMatrixWithTieredPricingPrice - .scalableMatrixWithTieredPricingConfig - billableMetricId = - newFloatingScalableMatrixWithTieredPricingPrice.billableMetricId - billedInAdvance = - newFloatingScalableMatrixWithTieredPricingPrice.billedInAdvance + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance billingCycleConfiguration = - newFloatingScalableMatrixWithTieredPricingPrice.billingCycleConfiguration - conversionRate = newFloatingScalableMatrixWithTieredPricingPrice.conversionRate - externalPriceId = - newFloatingScalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = - newFloatingScalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingScalableMatrixWithTieredPricingPrice.invoiceGroupingKey + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingScalableMatrixWithTieredPricingPrice.invoicingCycleConfiguration - metadata = newFloatingScalableMatrixWithTieredPricingPrice.metadata + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithTieredPricing.metadata additionalProperties = - newFloatingScalableMatrixWithTieredPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -59565,18 +55555,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -59870,8 +55861,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewFloatingScalableMatrixWithTieredPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -59880,19 +55870,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingScalableMatrixWithTieredPricingPrice = - NewFloatingScalableMatrixWithTieredPricingPrice( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithTieredPricingConfig", @@ -59913,7 +55902,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingScalableMatrixWithTieredPricingPrice = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } @@ -59921,7 +55910,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -59955,7 +55948,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -60124,135 +56119,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - 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 ScalableMatrixWithTieredPricingConfig @JsonCreator private constructor( @@ -61199,7 +57065,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithTieredPricing && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -61209,16 +57075,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingCumulativeGroupedBulkPrice + class CumulativeGroupedBulk private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -61247,9 +57113,7 @@ private constructor( @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("model_type") - @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + @JsonProperty("model_type") @ExcludeMissing modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("billable_metric_id") @ExcludeMissing @@ -61334,11 +57198,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -61465,16 +57333,6 @@ private constructor( */ @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]. * @@ -61590,7 +57448,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingCumulativeGroupedBulkPrice]. + * [CumulativeGroupedBulk]. * * The following fields are required: * ```java @@ -61598,14 +57456,13 @@ private constructor( * .cumulativeGroupedBulkConfig() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingCumulativeGroupedBulkPrice]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -61613,7 +57470,7 @@ private constructor( null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -61629,29 +57486,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ) = apply { - cadence = newFloatingCumulativeGroupedBulkPrice.cadence - cumulativeGroupedBulkConfig = - newFloatingCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - currency = newFloatingCumulativeGroupedBulkPrice.currency - itemId = newFloatingCumulativeGroupedBulkPrice.itemId - modelType = newFloatingCumulativeGroupedBulkPrice.modelType - name = newFloatingCumulativeGroupedBulkPrice.name - billableMetricId = newFloatingCumulativeGroupedBulkPrice.billableMetricId - billedInAdvance = newFloatingCumulativeGroupedBulkPrice.billedInAdvance - billingCycleConfiguration = - newFloatingCumulativeGroupedBulkPrice.billingCycleConfiguration - conversionRate = newFloatingCumulativeGroupedBulkPrice.conversionRate - externalPriceId = newFloatingCumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = newFloatingCumulativeGroupedBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingCumulativeGroupedBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingCumulativeGroupedBulkPrice.invoicingCycleConfiguration - metadata = newFloatingCumulativeGroupedBulkPrice.metadata - additionalProperties = - newFloatingCumulativeGroupedBulkPrice.additionalProperties.toMutableMap() + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence + cumulativeGroupedBulkConfig = cumulativeGroupedBulk.cumulativeGroupedBulkConfig + currency = cumulativeGroupedBulk.currency + itemId = cumulativeGroupedBulk.itemId + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey + invoicingCycleConfiguration = cumulativeGroupedBulk.invoicingCycleConfiguration + metadata = cumulativeGroupedBulk.metadata + additionalProperties = cumulativeGroupedBulk.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -61705,18 +57556,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -61988,7 +57840,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingCumulativeGroupedBulkPrice]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -61998,19 +57850,18 @@ private constructor( * .cumulativeGroupedBulkConfig() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingCumulativeGroupedBulkPrice = - NewFloatingCumulativeGroupedBulkPrice( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("cadence", cadence), checkRequired("cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -62027,7 +57878,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingCumulativeGroupedBulkPrice = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -62036,7 +57887,11 @@ private constructor( cumulativeGroupedBulkConfig().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -62070,7 +57925,9 @@ private constructor( (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -62351,131 +58208,6 @@ private constructor( "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" } - class ModelType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * 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 { - CUMULATIVE_GROUPED_BULK, - /** - * 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) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or months. */ @@ -63307,7 +59039,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CumulativeGroupedBulk && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -63317,7 +59049,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, 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/PriceEvaluateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt index 9b4dd102..2e0cc4af 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 @@ -44,13 +44,13 @@ import kotlin.jvm.optionals.getOrNull */ class PriceEvaluateParams private constructor( - private val priceId: String, + private val priceId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun priceId(): String = priceId + fun priceId(): Optional = Optional.ofNullable(priceId) /** * The exclusive upper bound for event timestamps @@ -160,7 +160,6 @@ private constructor( * * The following fields are required: * ```java - * .priceId() * .timeframeEnd() * .timeframeStart() * ``` @@ -184,7 +183,10 @@ private constructor( additionalQueryParams = priceEvaluateParams.additionalQueryParams.toBuilder() } - fun priceId(priceId: String) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = apply { this.priceId = priceId } + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) /** * Sets the entire request body. @@ -433,7 +435,6 @@ private constructor( * * The following fields are required: * ```java - * .priceId() * .timeframeEnd() * .timeframeStart() * ``` @@ -442,7 +443,7 @@ private constructor( */ fun build(): PriceEvaluateParams = PriceEvaluateParams( - checkRequired("priceId", priceId), + priceId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -453,7 +454,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> priceId + 0 -> priceId ?: "" else -> "" } 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 4beee51b..bdbe1002 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint returns a price given an external price id. See the @@ -15,12 +16,12 @@ import java.util.Objects */ class PriceExternalPriceIdFetchParams private constructor( - private val externalPriceId: String, + private val externalPriceId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun externalPriceId(): String = externalPriceId + fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) fun _additionalHeaders(): Headers = additionalHeaders @@ -30,14 +31,11 @@ private constructor( companion object { + @JvmStatic fun none(): PriceExternalPriceIdFetchParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [PriceExternalPriceIdFetchParams]. - * - * The following fields are required: - * ```java - * .externalPriceId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -58,10 +56,14 @@ private constructor( priceExternalPriceIdFetchParams.additionalQueryParams.toBuilder() } - fun externalPriceId(externalPriceId: String) = apply { + fun externalPriceId(externalPriceId: String?) = apply { this.externalPriceId = externalPriceId } + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -164,17 +166,10 @@ private constructor( * Returns an immutable instance of [PriceExternalPriceIdFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams( - checkRequired("externalPriceId", externalPriceId), + externalPriceId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -182,7 +177,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalPriceId + 0 -> externalPriceId ?: "" else -> "" } 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 8b82adef..9775d92b 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 @@ -11,7 +11,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -27,13 +26,13 @@ import kotlin.jvm.optionals.getOrNull */ class PriceExternalPriceIdUpdateParams private constructor( - private val externalPriceId: String, + private val externalPriceId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun externalPriceId(): String = externalPriceId + fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting @@ -62,14 +61,11 @@ private constructor( companion object { + @JvmStatic fun none(): PriceExternalPriceIdUpdateParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [PriceExternalPriceIdUpdateParams]. - * - * The following fields are required: - * ```java - * .externalPriceId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -92,10 +88,14 @@ private constructor( priceExternalPriceIdUpdateParams.additionalQueryParams.toBuilder() } - fun externalPriceId(externalPriceId: String) = apply { + fun externalPriceId(externalPriceId: String?) = apply { this.externalPriceId = externalPriceId } + /** Alias for calling [Builder.externalPriceId] with `externalPriceId.orElse(null)`. */ + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.getOrNull()) + /** * Sets the entire request body. * @@ -245,17 +245,10 @@ private constructor( * Returns an immutable instance of [PriceExternalPriceIdUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .externalPriceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams( - checkRequired("externalPriceId", externalPriceId), + externalPriceId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -266,7 +259,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> externalPriceId + 0 -> externalPriceId ?: "" else -> "" } 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 0597f89e..9f4831e6 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 @@ -3,20 +3,21 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** This endpoint returns a price given an identifier. */ class PriceFetchParams private constructor( - private val priceId: String, + private val priceId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun priceId(): String = priceId + fun priceId(): Optional = Optional.ofNullable(priceId) fun _additionalHeaders(): Headers = additionalHeaders @@ -26,14 +27,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [PriceFetchParams]. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - */ + @JvmStatic fun none(): PriceFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PriceFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -51,7 +47,10 @@ private constructor( additionalQueryParams = priceFetchParams.additionalQueryParams.toBuilder() } - fun priceId(priceId: String) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = apply { this.priceId = priceId } + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -155,25 +154,14 @@ private constructor( * Returns an immutable instance of [PriceFetchParams]. * * 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(): PriceFetchParams = - PriceFetchParams( - checkRequired("priceId", priceId), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + PriceFetchParams(priceId, additionalHeaders.build(), additionalQueryParams.build()) } fun _pathParam(index: Int): String = when (index) { - 0 -> priceId + 0 -> priceId ?: "" else -> "" } 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 90ac2e31..852625a9 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.PriceService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [PriceService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: PriceService, private val params: PriceListParams, private val response: PriceListPageResponse, -) { +) : Page { /** * Delegates to [PriceListPageResponse], but gracefully handles missing data. @@ -33,30 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): PriceListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): PriceListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): PriceListParams = params @@ -125,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: PriceListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 e38c33a4..7d5b880e 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.PriceServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [PriceServiceAsync.list] */ class PriceListPageAsync private constructor( private val service: PriceServiceAsync, + private val streamHandlerExecutor: Executor, private val params: PriceListParams, private val response: PriceListPageResponse, -) { +) : PageAsync { /** * Delegates to [PriceListPageResponse], but gracefully handles missing data. @@ -34,33 +36,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): PriceListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): PriceListParams = params @@ -78,6 +69,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -89,18 +81,24 @@ private constructor( class Builder internal constructor() { private var service: PriceServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: PriceListParams? = null private var response: PriceListPageResponse? = null @JvmSynthetic internal fun from(priceListPageAsync: PriceListPageAsync) = apply { service = priceListPageAsync.service + streamHandlerExecutor = priceListPageAsync.streamHandlerExecutor params = priceListPageAsync.params response = priceListPageAsync.response } fun service(service: PriceServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: PriceListParams) = apply { this.params = params } @@ -115,6 +113,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -124,47 +123,22 @@ private constructor( fun build(): PriceListPageAsync = PriceListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: PriceListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Price) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PriceListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is PriceListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "PriceListPageAsync{service=$service, params=$params, response=$response}" + "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 6d09727c..71723f6c 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 @@ -129,136 +129,136 @@ private constructor( } /** Alias for calling [addData] with `Price.ofUnit(unit)`. */ - fun addData(unit: Price.UnitPrice) = addData(Price.ofUnit(unit)) + fun addData(unit: Price.Unit) = addData(Price.ofUnit(unit)) - /** Alias for calling [addData] with `Price.ofPackagePrice(packagePrice)`. */ - fun addData(packagePrice: Price.PackagePrice) = addData(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = addData(Price.ofMatrix(matrix)) + fun addData(matrix: Price.Matrix) = addData(Price.ofMatrix(matrix)) /** Alias for calling [addData] with `Price.ofTiered(tiered)`. */ - fun addData(tiered: Price.TieredPrice) = addData(Price.ofTiered(tiered)) + fun addData(tiered: Price.Tiered) = addData(Price.ofTiered(tiered)) /** Alias for calling [addData] with `Price.ofTieredBps(tieredBps)`. */ - fun addData(tieredBps: Price.TieredBpsPrice) = addData(Price.ofTieredBps(tieredBps)) + fun addData(tieredBps: Price.TieredBps) = addData(Price.ofTieredBps(tieredBps)) /** Alias for calling [addData] with `Price.ofBps(bps)`. */ - fun addData(bps: Price.BpsPrice) = addData(Price.ofBps(bps)) + fun addData(bps: Price.Bps) = addData(Price.ofBps(bps)) /** Alias for calling [addData] with `Price.ofBulkBps(bulkBps)`. */ - fun addData(bulkBps: Price.BulkBpsPrice) = addData(Price.ofBulkBps(bulkBps)) + fun addData(bulkBps: Price.BulkBps) = addData(Price.ofBulkBps(bulkBps)) /** Alias for calling [addData] with `Price.ofBulk(bulk)`. */ - fun addData(bulk: Price.BulkPrice) = addData(Price.ofBulk(bulk)) + fun addData(bulk: Price.Bulk) = addData(Price.ofBulk(bulk)) /** * Alias for calling [addData] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun addData(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun addData(thresholdTotalAmount: Price.ThresholdTotalAmount) = addData(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [addData] with `Price.ofTieredPackage(tieredPackage)`. */ - fun addData(tieredPackage: Price.TieredPackagePrice) = + fun addData(tieredPackage: Price.TieredPackage) = addData(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [addData] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun addData(groupedTiered: Price.GroupedTieredPrice) = + fun addData(groupedTiered: Price.GroupedTiered) = addData(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [addData] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun addData(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun addData(tieredWithMinimum: Price.TieredWithMinimum) = addData(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [addData] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun addData(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun addData(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = addData(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [addData] with `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun addData(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun addData(packageWithAllocation: Price.PackageWithAllocation) = addData(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [addData] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun addData(unitWithPercent: Price.UnitWithPercentPrice) = + fun addData(unitWithPercent: Price.UnitWithPercent) = addData(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [addData] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun addData(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun addData(matrixWithAllocation: Price.MatrixWithAllocation) = addData(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** Alias for calling [addData] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun addData(tieredWithProration: Price.TieredWithProrationPrice) = + fun addData(tieredWithProration: Price.TieredWithProration) = addData(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [addData] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun addData(unitWithProration: Price.UnitWithProrationPrice) = + fun addData(unitWithProration: Price.UnitWithProration) = addData(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [addData] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun addData(groupedAllocation: Price.GroupedAllocationPrice) = + fun addData(groupedAllocation: Price.GroupedAllocation) = addData(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [addData] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun addData(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun addData(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = addData(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [addData] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun addData(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun addData(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = addData(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [addData] with `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun addData(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun addData(matrixWithDisplayName: Price.MatrixWithDisplayName) = addData(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [addData] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun addData(bulkWithProration: Price.BulkWithProrationPrice) = + fun addData(bulkWithProration: Price.BulkWithProration) = addData(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [addData] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun addData(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun addData(groupedTieredPackage: Price.GroupedTieredPackage) = addData(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [addData] with `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun addData(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun addData(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = addData(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [addData] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun addData(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun addData(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = addData(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [addData] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun addData(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun addData(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = addData(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [addData] with `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun addData(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun addData(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = addData(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) fun paginationMetadata(paginationMetadata: PaginationMetadata) = 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 a73648e2..96660b94 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 @@ -11,7 +11,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -27,13 +26,13 @@ import kotlin.jvm.optionals.getOrNull */ class PriceUpdateParams private constructor( - private val priceId: String, + private val priceId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun priceId(): String = priceId + fun priceId(): Optional = Optional.ofNullable(priceId) /** * User-specified key/value pairs for the resource. Individual keys can be removed by setting @@ -62,14 +61,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [PriceUpdateParams]. - * - * The following fields are required: - * ```java - * .priceId() - * ``` - */ + @JvmStatic fun none(): PriceUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PriceUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -89,7 +83,10 @@ private constructor( additionalQueryParams = priceUpdateParams.additionalQueryParams.toBuilder() } - fun priceId(priceId: String) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = apply { this.priceId = priceId } + + /** Alias for calling [Builder.priceId] with `priceId.orElse(null)`. */ + fun priceId(priceId: Optional) = priceId(priceId.getOrNull()) /** * Sets the entire request body. @@ -240,17 +237,10 @@ private constructor( * Returns an immutable instance of [PriceUpdateParams]. * * 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(): PriceUpdateParams = PriceUpdateParams( - checkRequired("priceId", priceId), + priceId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -261,7 +251,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> priceId + 0 -> priceId ?: "" else -> "" } 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 94fc2b50..1d210e99 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 @@ -1040,17 +1040,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1668,41 +1668,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1851,66 +1838,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1923,34 +1900,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -1975,25 +1944,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2004,21 +1967,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2026,27 +1987,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2055,21 +2009,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2095,44 +2043,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2148,26 +2081,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2181,7 +2110,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2216,11 +2145,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2276,16 +2211,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2349,13 +2274,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2366,11 +2289,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2379,21 +2302,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2407,17 +2325,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2552,14 +2472,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2569,10 +2488,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2586,13 +2505,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2618,149 +2543,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2770,13 +2567,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2790,7 +2587,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2825,11 +2622,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2885,16 +2688,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -2958,13 +2751,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -2975,11 +2766,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -2988,21 +2779,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3016,17 +2802,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3161,14 +2949,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3178,10 +2965,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3195,13 +2982,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3227,149 +3020,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3379,13 +3044,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3399,7 +3064,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3434,11 +3099,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3495,16 +3166,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3569,12 +3230,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3585,11 +3245,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3598,23 +3258,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3628,17 +3282,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3773,14 +3429,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3790,10 +3445,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3807,13 +3462,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3839,149 +3500,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3991,13 +3524,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4012,7 +3545,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4051,11 +3584,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4121,19 +3660,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4201,13 +3730,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4219,11 +3746,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4233,22 +3760,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4261,17 +3783,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4418,14 +3942,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4436,10 +3959,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4454,13 +3977,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4487,7 +4016,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4495,142 +4024,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4640,13 +4039,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4660,7 +4059,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4695,11 +4094,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4755,16 +4160,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4828,13 +4223,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4845,11 +4238,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4858,21 +4251,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4885,17 +4273,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5030,14 +4420,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5047,10 +4436,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5064,13 +4453,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5096,149 +4491,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5248,7 +4513,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5541,17 +4806,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5559,11 +4824,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5584,15 +4849,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5618,12 +4883,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5650,14 +4914,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5666,11 +4928,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5696,17 +4958,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5733,12 +4995,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5757,7 +5019,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5804,11 +5066,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5857,16 +5125,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5901,15 +5159,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5917,29 +5173,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6014,17 +5268,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6080,7 +5336,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6089,15 +5345,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6105,7 +5360,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6114,7 +5369,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6122,7 +5377,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6147,143 +5406,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6293,14 +5425,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6317,7 +5449,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6358,11 +5490,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6410,16 +5548,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6464,14 +5592,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6480,31 +5606,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6564,17 +5686,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6647,7 +5771,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6655,7 +5779,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6663,15 +5786,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6681,14 +5804,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6713,144 +5840,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6860,14 +5860,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6884,7 +5884,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6925,11 +5925,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6978,16 +5984,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7032,14 +6028,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7048,28 +6042,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7129,17 +6122,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7213,7 +6208,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7221,7 +6216,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7229,15 +6223,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7247,14 +6241,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7279,144 +6277,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7426,7 +6297,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9226,142 +8097,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 983b9bc3..ccc31668 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 @@ -75,13 +75,13 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionCancelParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * Determines the timing of subscription cancellation @@ -148,7 +148,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .cancelOption() * ``` */ @@ -171,7 +170,11 @@ private constructor( additionalQueryParams = subscriptionCancelParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Sets the entire request body. @@ -380,7 +383,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .cancelOption() * ``` * @@ -388,7 +390,7 @@ private constructor( */ fun build(): SubscriptionCancelParams = SubscriptionCancelParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -399,7 +401,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt index b1147de0..54ec6d66 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt @@ -1056,17 +1056,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1710,41 +1710,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1893,66 +1880,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1965,34 +1942,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2017,25 +1986,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2046,21 +2009,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2068,27 +2029,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2097,21 +2051,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2137,44 +2085,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2190,26 +2123,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2223,7 +2152,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2258,11 +2187,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2318,16 +2253,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2391,13 +2316,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2408,11 +2331,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2421,21 +2344,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2449,17 +2367,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2594,14 +2514,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2611,10 +2530,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2628,13 +2547,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2660,149 +2585,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2812,13 +2609,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2832,7 +2629,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2867,11 +2664,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2927,16 +2730,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3000,13 +2793,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3017,11 +2808,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3030,21 +2821,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3058,17 +2844,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3203,14 +2991,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3220,10 +3007,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3237,13 +3024,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3269,149 +3062,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3421,13 +3086,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3441,7 +3106,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3476,11 +3141,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3537,16 +3208,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3611,12 +3272,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3627,11 +3287,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3640,23 +3300,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3670,17 +3324,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3815,14 +3471,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3832,10 +3487,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3849,13 +3504,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3881,149 +3542,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4033,13 +3566,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4054,7 +3587,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4093,11 +3626,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4163,19 +3702,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4243,13 +3772,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4261,11 +3788,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4275,22 +3802,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4303,17 +3825,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4460,14 +3984,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4478,10 +4001,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4496,13 +4019,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4529,7 +4058,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4537,142 +4066,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4682,13 +4081,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4702,7 +4101,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4737,11 +4136,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4797,16 +4202,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4870,13 +4265,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4887,11 +4280,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4900,21 +4293,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4927,17 +4315,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5072,14 +4462,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5089,10 +4478,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5106,13 +4495,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5138,149 +4533,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5290,7 +4555,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5583,17 +4848,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5601,11 +4866,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5626,15 +4891,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5660,12 +4925,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5692,14 +4956,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5708,11 +4970,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5738,17 +5000,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5775,12 +5037,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5799,7 +5061,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5846,11 +5108,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5899,16 +5167,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5943,15 +5201,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5959,29 +5215,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6056,17 +5310,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6122,7 +5378,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6131,15 +5387,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6147,7 +5402,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6156,7 +5411,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6164,7 +5419,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6189,143 +5448,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6335,14 +5467,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6359,7 +5491,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6400,11 +5532,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6452,16 +5590,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6506,14 +5634,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6522,31 +5648,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6606,17 +5728,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6689,7 +5813,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6697,7 +5821,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6705,15 +5828,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6723,14 +5846,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6755,144 +5882,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6902,14 +5902,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6926,7 +5926,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6967,11 +5967,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7020,16 +6026,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7074,14 +6070,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7090,28 +6084,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7171,17 +6164,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7255,7 +6250,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7263,7 +6258,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7271,15 +6265,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7289,14 +6283,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7321,144 +6319,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7468,7 +6339,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9268,142 +8139,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 986120fa..554f3ac5 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 @@ -11,7 +11,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException @@ -27,13 +26,13 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionChangeApplyParams private constructor( - private val subscriptionChangeId: String, + private val subscriptionChangeId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionChangeId(): String = subscriptionChangeId + fun subscriptionChangeId(): Optional = Optional.ofNullable(subscriptionChangeId) /** * Description to apply to the balance transaction representing this credit. @@ -76,14 +75,11 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionChangeApplyParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [SubscriptionChangeApplyParams]. - * - * The following fields are required: - * ```java - * .subscriptionChangeId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -104,10 +100,17 @@ private constructor( additionalQueryParams = subscriptionChangeApplyParams.additionalQueryParams.toBuilder() } - fun subscriptionChangeId(subscriptionChangeId: String) = apply { + fun subscriptionChangeId(subscriptionChangeId: String?) = apply { this.subscriptionChangeId = subscriptionChangeId } + /** + * Alias for calling [Builder.subscriptionChangeId] with + * `subscriptionChangeId.orElse(null)`. + */ + fun subscriptionChangeId(subscriptionChangeId: Optional) = + subscriptionChangeId(subscriptionChangeId.getOrNull()) + /** * Sets the entire request body. * @@ -277,17 +280,10 @@ private constructor( * Returns an immutable instance of [SubscriptionChangeApplyParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionChangeId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionChangeApplyParams = SubscriptionChangeApplyParams( - checkRequired("subscriptionChangeId", subscriptionChangeId), + subscriptionChangeId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -298,7 +294,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionChangeId + 0 -> subscriptionChangeId ?: "" else -> "" } 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 4943568e..82791826 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 @@ -1558,18 +1558,18 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with * `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -2237,45 +2237,32 @@ private constructor( } /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment( - planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment( - planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = - adjustment( - Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount) - ) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = + adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = + adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -2428,67 +2415,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = - null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -2501,34 +2477,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2553,25 +2521,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2582,21 +2544,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2604,27 +2564,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2633,21 +2586,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2678,45 +2625,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Adjustment(planPhasePercentageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2732,26 +2663,24 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2767,7 +2696,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2802,12 +2731,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2864,16 +2798,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2940,12 +2864,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2956,11 +2879,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2970,21 +2893,16 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2998,17 +2916,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3144,14 +3064,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -3161,10 +3080,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3178,13 +3097,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -3210,150 +3135,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3363,13 +3159,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -3385,7 +3181,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -3420,12 +3216,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a @@ -3482,16 +3283,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3558,12 +3349,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3574,11 +3364,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3588,22 +3378,17 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties - .toMutableMap() + amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3617,17 +3402,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3763,14 +3550,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3780,10 +3566,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3797,13 +3583,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3829,150 +3621,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3982,13 +3645,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -4004,7 +3667,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4039,12 +3702,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4102,16 +3770,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4178,12 +3836,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -4194,11 +3851,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = + JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -4208,24 +3866,17 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: - PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -4239,17 +3890,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4385,14 +4038,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -4402,10 +4054,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4419,13 +4071,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -4451,150 +4109,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4604,13 +4133,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4627,7 +4156,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4666,13 +4195,18 @@ private constructor( 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 adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") - + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType + /** * The price IDs that this adjustment applies to. * @@ -4737,16 +4271,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4822,13 +4346,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4840,11 +4362,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4855,22 +4377,17 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4883,17 +4400,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5041,14 +4560,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -5059,10 +4577,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5077,13 +4595,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -5110,7 +4634,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -5118,143 +4642,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5264,13 +4657,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -5286,7 +4679,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -5321,12 +4714,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -5383,16 +4781,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -5458,13 +4846,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5475,11 +4861,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -5489,21 +4875,16 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -5516,17 +4897,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5662,14 +5045,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5679,10 +5061,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5696,13 +5078,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5728,150 +5116,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5881,7 +5138,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -6179,17 +5436,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -6197,11 +5454,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -6222,15 +5479,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -6256,12 +5513,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -6288,15 +5544,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic - fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -6305,11 +5558,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -6336,22 +5589,19 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(amount = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(usage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -6376,12 +5626,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -6400,7 +5650,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6447,11 +5697,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6501,16 +5757,6 @@ private constructor( fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6546,15 +5792,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -6562,31 +5806,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6662,17 +5902,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6730,7 +5972,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6739,22 +5981,21 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) .map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6763,7 +6004,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6771,7 +6012,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6796,146 +6041,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6945,14 +6060,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6969,7 +6084,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -7010,11 +6125,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7064,16 +6185,6 @@ private constructor( fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7119,14 +6230,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -7135,35 +6244,28 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = - apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { - it.toMutableList() - } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() + } /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: List) = @@ -7223,17 +6325,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7309,7 +6413,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7317,7 +6421,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -7325,14 +6428,14 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) .map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -7342,14 +6445,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -7374,147 +6481,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7524,14 +6501,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -7548,7 +6525,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -7589,11 +6566,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7643,16 +6626,6 @@ private constructor( fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7698,14 +6671,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7714,31 +6685,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = - usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7799,17 +6766,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7885,7 +6854,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7893,7 +6862,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7901,14 +6869,14 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) .map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7918,14 +6886,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7950,147 +6922,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -8100,7 +6942,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9955,156 +8797,154 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = - price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with * `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 8e7d2940..d5b2dc6a 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * Cancel a subscription change. The change can no longer be applied. A subscription can only have @@ -18,13 +18,13 @@ import java.util.Optional */ class SubscriptionChangeCancelParams private constructor( - private val subscriptionChangeId: String, + private val subscriptionChangeId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun subscriptionChangeId(): String = subscriptionChangeId + fun subscriptionChangeId(): Optional = Optional.ofNullable(subscriptionChangeId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -36,14 +36,11 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionChangeCancelParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [SubscriptionChangeCancelParams]. - * - * The following fields are required: - * ```java - * .subscriptionChangeId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -65,10 +62,17 @@ private constructor( subscriptionChangeCancelParams.additionalBodyProperties.toMutableMap() } - fun subscriptionChangeId(subscriptionChangeId: String) = apply { + fun subscriptionChangeId(subscriptionChangeId: String?) = apply { this.subscriptionChangeId = subscriptionChangeId } + /** + * Alias for calling [Builder.subscriptionChangeId] with + * `subscriptionChangeId.orElse(null)`. + */ + fun subscriptionChangeId(subscriptionChangeId: Optional) = + subscriptionChangeId(subscriptionChangeId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -193,17 +197,10 @@ private constructor( * Returns an immutable instance of [SubscriptionChangeCancelParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionChangeId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionChangeCancelParams = SubscriptionChangeCancelParams( - checkRequired("subscriptionChangeId", subscriptionChangeId), + subscriptionChangeId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -215,7 +212,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionChangeId + 0 -> subscriptionChangeId ?: "" else -> "" } 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 8706a849..fbffe6af 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 @@ -1558,18 +1558,18 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with * `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -2237,45 +2237,32 @@ private constructor( } /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment( - planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment( - planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = - adjustment( - Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount) - ) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = + adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = + adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -2428,67 +2415,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = - null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -2501,34 +2477,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2553,25 +2521,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2582,21 +2544,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2604,27 +2564,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2633,21 +2586,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2678,45 +2625,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Adjustment(planPhasePercentageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2732,26 +2663,24 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2767,7 +2696,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2802,12 +2731,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2864,16 +2798,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2940,12 +2864,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2956,11 +2879,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2970,21 +2893,16 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2998,17 +2916,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3144,14 +3064,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -3161,10 +3080,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3178,13 +3097,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -3210,150 +3135,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3363,13 +3159,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -3385,7 +3181,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -3420,12 +3216,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a @@ -3482,16 +3283,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3558,12 +3349,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3574,11 +3364,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3588,22 +3378,17 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties - .toMutableMap() + amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3617,17 +3402,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3763,14 +3550,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3780,10 +3566,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3797,13 +3583,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3829,150 +3621,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3982,13 +3645,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -4004,7 +3667,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4039,12 +3702,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4102,16 +3770,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4178,12 +3836,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -4194,11 +3851,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = + JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -4208,24 +3866,17 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: - PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -4239,17 +3890,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4385,14 +4038,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -4402,10 +4054,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4419,13 +4071,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -4451,150 +4109,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4604,13 +4133,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4627,7 +4156,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4666,13 +4195,18 @@ private constructor( 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 adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") - + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType + /** * The price IDs that this adjustment applies to. * @@ -4737,16 +4271,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4822,13 +4346,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4840,11 +4362,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4855,22 +4377,17 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4883,17 +4400,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5041,14 +4560,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -5059,10 +4577,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5077,13 +4595,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -5110,7 +4634,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -5118,143 +4642,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5264,13 +4657,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -5286,7 +4679,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -5321,12 +4714,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -5383,16 +4781,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -5458,13 +4846,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5475,11 +4861,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -5489,21 +4875,16 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -5516,17 +4897,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5662,14 +5045,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5679,10 +5061,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5696,13 +5078,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5728,150 +5116,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5881,7 +5138,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -6179,17 +5436,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -6197,11 +5454,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -6222,15 +5479,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -6256,12 +5513,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -6288,15 +5544,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic - fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -6305,11 +5558,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -6336,22 +5589,19 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(amount = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(usage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -6376,12 +5626,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -6400,7 +5650,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6447,11 +5697,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6501,16 +5757,6 @@ private constructor( fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6546,15 +5792,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -6562,31 +5806,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6662,17 +5902,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6730,7 +5972,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6739,22 +5981,21 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) .map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6763,7 +6004,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6771,7 +6012,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6796,146 +6041,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6945,14 +6060,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6969,7 +6084,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -7010,11 +6125,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7064,16 +6185,6 @@ private constructor( fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7119,14 +6230,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -7135,35 +6244,28 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = - apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { - it.toMutableList() - } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() + } /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: List) = @@ -7223,17 +6325,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7309,7 +6413,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7317,7 +6421,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -7325,14 +6428,14 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) .map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -7342,14 +6445,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -7374,147 +6481,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7524,14 +6501,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -7548,7 +6525,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -7589,11 +6566,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7643,16 +6626,6 @@ private constructor( fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7698,14 +6671,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7714,31 +6685,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = - usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7799,17 +6766,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7885,7 +6854,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7893,7 +6862,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7901,14 +6869,14 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) .map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7918,14 +6886,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7950,147 +6922,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -8100,7 +6942,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9955,156 +8797,154 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = - price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with * `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 91cf124c..ec3ab846 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint returns a subscription change given an identifier. @@ -19,12 +20,12 @@ import java.util.Objects */ class SubscriptionChangeRetrieveParams private constructor( - private val subscriptionChangeId: String, + private val subscriptionChangeId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionChangeId(): String = subscriptionChangeId + fun subscriptionChangeId(): Optional = Optional.ofNullable(subscriptionChangeId) fun _additionalHeaders(): Headers = additionalHeaders @@ -34,14 +35,11 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionChangeRetrieveParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [SubscriptionChangeRetrieveParams]. - * - * The following fields are required: - * ```java - * .subscriptionChangeId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -62,10 +60,17 @@ private constructor( subscriptionChangeRetrieveParams.additionalQueryParams.toBuilder() } - fun subscriptionChangeId(subscriptionChangeId: String) = apply { + fun subscriptionChangeId(subscriptionChangeId: String?) = apply { this.subscriptionChangeId = subscriptionChangeId } + /** + * Alias for calling [Builder.subscriptionChangeId] with + * `subscriptionChangeId.orElse(null)`. + */ + fun subscriptionChangeId(subscriptionChangeId: Optional) = + subscriptionChangeId(subscriptionChangeId.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -168,17 +173,10 @@ private constructor( * Returns an immutable instance of [SubscriptionChangeRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionChangeId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionChangeRetrieveParams = SubscriptionChangeRetrieveParams( - checkRequired("subscriptionChangeId", subscriptionChangeId), + subscriptionChangeId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -186,7 +184,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionChangeId + 0 -> subscriptionChangeId ?: "" else -> "" } 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 41b9fa0b..e62a3d9a 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 @@ -1558,18 +1558,18 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with * `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -2237,45 +2237,32 @@ private constructor( } /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ - fun adjustment( - planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment( - planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = - adjustment( - Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount) - ) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = + adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = + adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -2428,67 +2415,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = - null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -2501,34 +2477,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2553,25 +2521,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2582,21 +2544,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2604,27 +2564,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2633,21 +2586,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2678,45 +2625,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Adjustment(planPhasePercentageDiscount = it, _json = json) - } ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Adjustment(percentageDiscount = it, _json = json) } + ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2732,26 +2663,24 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2767,7 +2696,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2802,12 +2731,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2864,16 +2798,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2940,12 +2864,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2956,11 +2879,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2970,21 +2893,16 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2998,17 +2916,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3144,14 +3064,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -3161,10 +3080,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3178,13 +3097,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -3210,150 +3135,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3363,13 +3159,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -3385,7 +3181,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -3420,12 +3216,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a @@ -3482,16 +3283,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3558,12 +3349,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3574,11 +3364,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3588,22 +3378,17 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties - .toMutableMap() + amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3617,17 +3402,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3763,14 +3550,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3780,10 +3566,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3797,13 +3583,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3829,150 +3621,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3982,13 +3645,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -4004,7 +3667,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4039,12 +3702,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4102,16 +3770,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4178,12 +3836,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -4194,11 +3851,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = + JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -4208,24 +3866,17 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: - PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -4239,17 +3890,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4385,14 +4038,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -4402,10 +4054,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4419,13 +4071,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -4451,150 +4109,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4604,13 +4133,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4627,7 +4156,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4666,13 +4195,18 @@ private constructor( 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 adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") - + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). + */ + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType + /** * The price IDs that this adjustment applies to. * @@ -4737,16 +4271,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4822,13 +4346,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4840,11 +4362,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4855,22 +4377,17 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4883,17 +4400,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5041,14 +4560,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -5059,10 +4577,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5077,13 +4595,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -5110,7 +4634,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -5118,143 +4642,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5264,13 +4657,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -5286,7 +4679,7 @@ private constructor( id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -5321,12 +4714,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the + * server responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = - adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -5383,16 +4781,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -5458,13 +4846,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5475,11 +4861,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -5489,21 +4875,16 @@ private constructor( mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -5516,17 +4897,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults + * to the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5662,14 +5045,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5679,10 +5061,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5696,13 +5078,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5728,150 +5116,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple - * of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with - * an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> - throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5881,7 +5138,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -6179,17 +5436,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -6197,11 +5454,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -6222,15 +5479,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -6256,12 +5513,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -6288,15 +5544,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic - fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -6305,11 +5558,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -6336,22 +5589,19 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(amount = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(amount = it, _json = json) + } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(usage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(usage = it, _json = json) + } ?: DiscountInterval(_json = json) } } @@ -6376,12 +5626,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -6400,7 +5650,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6447,11 +5697,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6501,16 +5757,6 @@ private constructor( fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6546,15 +5792,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -6562,31 +5806,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6662,17 +5902,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6730,7 +5972,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6739,22 +5981,21 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) .map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6763,7 +6004,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6771,7 +6012,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6796,146 +6041,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6945,14 +6060,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6969,7 +6084,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -7010,11 +6125,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7064,16 +6185,6 @@ private constructor( fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7119,14 +6230,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -7135,35 +6244,28 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = - apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { - it.toMutableList() - } - appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() - } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() + } /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: List) = @@ -7223,17 +6325,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7309,7 +6413,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7317,7 +6421,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -7325,14 +6428,14 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) .map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -7342,14 +6445,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -7374,147 +6481,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7524,14 +6501,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -7548,7 +6525,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -7589,11 +6566,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7643,16 +6626,6 @@ private constructor( fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7698,14 +6671,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7714,31 +6685,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = - usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7799,17 +6766,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7885,7 +6854,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7893,7 +6862,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7901,14 +6869,14 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds) .map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7918,14 +6886,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7950,147 +6922,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -8100,7 +6942,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9955,156 +8797,154 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = - price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with * `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 61e514f4..edad900f 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 @@ -32,6 +32,7 @@ import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.Unit as KUnit import kotlin.jvm.optionals.getOrNull /** @@ -3728,32 +3729,26 @@ private constructor( /** * Alias for calling [adjustment] with - * `Adjustment.ofNewPercentageDiscount(newPercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewUsageDiscount(newUsageDiscount)`. - */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewAmountDiscount(newAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMinimum(newMinimum)`. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMaximum(newMaximum)`. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** * The end date of the adjustment interval. This is the date that the adjustment will @@ -3901,60 +3896,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isNewMinimum(): Boolean = newMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isNewMaximum(): Boolean = newMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) + 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) } @@ -3966,27 +3957,27 @@ private constructor( } accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - newPercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -4011,19 +4002,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) = newPercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - newUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - newAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -4034,19 +4025,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ + 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 hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" + 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") } @@ -4054,22 +4045,20 @@ private constructor( companion object { @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -4078,15 +4067,15 @@ private constructor( */ interface Visitor { - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitNewMinimum(newMinimum: NewMinimum): T + fun visitMinimum(minimum: Minimum): T - fun visitNewMaximum(newMaximum: NewMaximum): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -4112,28 +4101,28 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(newPercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newUsageDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newAmountDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMinimum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMaximum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) } ?: Adjustment(_json = json) } } @@ -4150,23 +4139,21 @@ private constructor( provider: SerializerProvider, ) { when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) + 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") } } } - class NewPercentageDiscount + class PercentageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val percentageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -4177,7 +4164,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4196,11 +4183,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -4230,16 +4223,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4286,11 +4269,10 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPercentageDiscount]. + * [PercentageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` @@ -4298,37 +4280,39 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPercentageDiscount]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var percentageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.percentageDiscount = percentageDiscount.percentageDiscount + isInvoiceLevel = percentageDiscount.isInvoiceLevel additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4414,22 +4398,21 @@ private constructor( } /** - * Returns an immutable instance of [NewPercentageDiscount]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): PercentageDiscount = + PercentageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4441,12 +4424,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPercentageDiscount = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() percentageDiscount() isInvoiceLevel() @@ -4469,147 +4458,19 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4619,12 +4480,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "PercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewUsageDiscount + class UsageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val usageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -4635,7 +4496,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4654,11 +4515,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -4687,16 +4554,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4742,11 +4599,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewUsageDiscount]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` @@ -4754,36 +4610,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewUsageDiscount]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var usageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.usageDiscount = usageDiscount.usageDiscount + isInvoiceLevel = usageDiscount.isInvoiceLevel + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4869,22 +4727,21 @@ private constructor( } /** - * Returns an immutable instance of [NewUsageDiscount]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): UsageDiscount = + UsageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4896,12 +4753,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewUsageDiscount = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() usageDiscount() isInvoiceLevel() @@ -4924,147 +4787,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("usage_discount")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5074,12 +4807,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "UsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewAmountDiscount + class AmountDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -5090,7 +4823,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -5109,11 +4842,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -5142,16 +4881,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -5197,12 +4926,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewAmountDiscount]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` @@ -5210,36 +4937,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewAmountDiscount]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5325,22 +5054,21 @@ private constructor( } /** - * Returns an immutable instance of [NewAmountDiscount]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): AmountDiscount = + AmountDiscount( + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -5352,12 +5080,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewAmountDiscount = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -5380,147 +5114,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("amount_discount")) 1 else 0 } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5530,12 +5134,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "AmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMinimum + class Minimum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val itemId: JsonField, private val minimumAmount: JsonField, @@ -5547,7 +5151,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -5570,11 +5174,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -5612,16 +5222,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -5675,11 +5275,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMinimum]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -5688,10 +5287,10 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMinimum]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var itemId: JsonField? = null private var minimumAmount: JsonField? = null @@ -5699,26 +5298,28 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() + internal fun from(minimum: Minimum) = apply { + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + isInvoiceLevel = minimum.isInvoiceLevel + additionalProperties = minimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5816,13 +5417,12 @@ private constructor( } /** - * Returns an immutable instance of [NewMinimum]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -5830,9 +5430,9 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Minimum = + Minimum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5845,12 +5445,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMinimum = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() itemId() minimumAmount() @@ -5874,148 +5480,18 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6025,12 +5501,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Minimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMaximum + class Maximum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val maximumAmount: JsonField, private val isInvoiceLevel: JsonField, @@ -6041,7 +5517,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -6060,11 +5536,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -6093,16 +5575,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -6148,11 +5620,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMaximum]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` @@ -6160,35 +5631,37 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMaximum]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var maximumAmount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() + internal fun from(maximum: Maximum) = apply { + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + maximumAmount = maximum.maximumAmount + isInvoiceLevel = maximum.isInvoiceLevel + additionalProperties = maximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -6274,22 +5747,21 @@ private constructor( } /** - * Returns an immutable instance of [NewMaximum]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Maximum = + Maximum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -6301,12 +5773,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMaximum = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() maximumAmount() isInvoiceLevel() @@ -6329,147 +5807,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6479,7 +5827,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Maximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } } @@ -6971,244 +6319,127 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } - /** - * Alias for calling [price] with `Price.ofNewSubscriptionUnit(newSubscriptionUnit)`. - */ - fun price(newSubscriptionUnit: Price.NewSubscriptionUnitPrice) = - price(Price.ofNewSubscriptionUnit(newSubscriptionUnit)) + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionPackage(newSubscriptionPackage)`. - */ - fun price(newSubscriptionPackage: Price.NewSubscriptionPackagePrice) = - price(Price.ofNewSubscriptionPackage(newSubscriptionPackage)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)`. - */ - fun price(newSubscriptionMatrix: Price.NewSubscriptionMatrixPrice) = - price(Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)) + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTiered(newSubscriptionTiered)`. - */ - fun price(newSubscriptionTiered: Price.NewSubscriptionTieredPrice) = - price(Price.ofNewSubscriptionTiered(newSubscriptionTiered)) + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)`. - */ - fun price(newSubscriptionTieredBps: Price.NewSubscriptionTieredBpsPrice) = - price(Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)) + /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - /** Alias for calling [price] with `Price.ofNewSubscriptionBps(newSubscriptionBps)`. */ - fun price(newSubscriptionBps: Price.NewSubscriptionBpsPrice) = - price(Price.ofNewSubscriptionBps(newSubscriptionBps)) + /** Alias for calling [price] with `Price.ofBps(bps)`. */ + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)`. - */ - fun price(newSubscriptionBulkBps: Price.NewSubscriptionBulkBpsPrice) = - price(Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)) + /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** - * Alias for calling [price] with `Price.ofNewSubscriptionBulk(newSubscriptionBulk)`. - */ - fun price(newSubscriptionBulk: Price.NewSubscriptionBulkPrice) = - price(Price.ofNewSubscriptionBulk(newSubscriptionBulk)) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount)`. + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price( - newSubscriptionThresholdTotalAmount: Price.NewSubscriptionThresholdTotalAmountPrice - ) = - price( - Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount) - ) + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)`. - */ - fun price(newSubscriptionTieredPackage: Price.NewSubscriptionTieredPackagePrice) = - price(Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)) + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: Price.TieredPackage) = + price(Price.ofTieredPackage(tieredPackage)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)`. - */ - fun price( - newSubscriptionTieredWithMinimum: Price.NewSubscriptionTieredWithMinimumPrice - ) = price(Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: Price.TieredWithMinimum) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)`. - */ - fun price(newSubscriptionUnitWithPercent: Price.NewSubscriptionUnitWithPercentPrice) = - price(Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: Price.UnitWithPercent) = + price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionPackageWithAllocation(newSubscriptionPackageWithAllocation)`. + * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price( - newSubscriptionPackageWithAllocation: - Price.NewSubscriptionPackageWithAllocationPrice - ) = - price( - Price.ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - ) + fun price(packageWithAllocation: Price.PackageWithAllocation) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)`. + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price( - newSubscriptionTierWithProration: Price.NewSubscriptionTierWithProrationPrice - ) = price(Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)) + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)`. - */ - fun price( - newSubscriptionUnitWithProration: Price.NewSubscriptionUnitWithProrationPrice - ) = price(Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: Price.UnitWithProration) = + price(Price.ofUnitWithProration(unitWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)`. - */ - fun price( - newSubscriptionGroupedAllocation: Price.NewSubscriptionGroupedAllocationPrice - ) = price(Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)) + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: Price.GroupedAllocation) = + price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedWithProratedMinimum(newSubscriptionGroupedWithProratedMinimum)`. + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price( - newSubscriptionGroupedWithProratedMinimum: - Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - ) + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)`. - */ - fun price( - newSubscriptionBulkWithProration: Price.NewSubscriptionBulkWithProrationPrice - ) = price(Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionScalableMatrixWithUnitPricing(newSubscriptionScalableMatrixWithUnitPricing)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price( - newSubscriptionScalableMatrixWithUnitPricing: - Price.NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = - price( - Price.ofNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing - ) - ) + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionScalableMatrixWithTieredPricing(newSubscriptionScalableMatrixWithTieredPricing)`. + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - newSubscriptionScalableMatrixWithTieredPricing: - Price.NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = - price( - Price.ofNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing - ) - ) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionCumulativeGroupedBulk(newSubscriptionCumulativeGroupedBulk)`. + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price( - newSubscriptionCumulativeGroupedBulk: - Price.NewSubscriptionCumulativeGroupedBulkPrice - ) = - price( - Price.ofNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk - ) - ) + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionMaxGroupTieredPackage(newSubscriptionMaxGroupTieredPackage)`. + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price( - newSubscriptionMaxGroupTieredPackage: - Price.NewSubscriptionMaxGroupTieredPackagePrice - ) = - price( - Price.ofNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage - ) - ) + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedWithMeteredMinimum(newSubscriptionGroupedWithMeteredMinimum)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price( - newSubscriptionGroupedWithMeteredMinimum: - Price.NewSubscriptionGroupedWithMeteredMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum - ) - ) + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionMatrixWithDisplayName(newSubscriptionMatrixWithDisplayName)`. + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price( - newSubscriptionMatrixWithDisplayName: - Price.NewSubscriptionMatrixWithDisplayNamePrice - ) = - price( - Price.ofNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName - ) - ) + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedTieredPackage(newSubscriptionGroupedTieredPackage)`. + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price( - newSubscriptionGroupedTieredPackage: Price.NewSubscriptionGroupedTieredPackagePrice - ) = - price( - Price.ofNewSubscriptionGroupedTieredPackage(newSubscriptionGroupedTieredPackage) - ) + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -8276,401 +7507,257 @@ private constructor( @JsonSerialize(using = Price.Serializer::class) class Price private constructor( - private val newSubscriptionUnit: NewSubscriptionUnitPrice? = null, - private val newSubscriptionPackage: NewSubscriptionPackagePrice? = null, - private val newSubscriptionMatrix: NewSubscriptionMatrixPrice? = null, - private val newSubscriptionTiered: NewSubscriptionTieredPrice? = null, - private val newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice? = null, - private val newSubscriptionBps: NewSubscriptionBpsPrice? = null, - private val newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice? = null, - private val newSubscriptionBulk: NewSubscriptionBulkPrice? = null, - private val newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice? = - null, - private val newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = - null, - private val newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice? = - null, - private val newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice? = - null, - private val newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice? = - null, - private val newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice? = - null, - private val newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice? = - null, - private val newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice? = - null, - private val newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice? = - null, - private val newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice? = - null, - private val newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice? = - null, + 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 thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val bulkWithProration: BulkWithProration? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, private val _json: JsonValue? = null, ) { - fun newSubscriptionUnit(): Optional = - Optional.ofNullable(newSubscriptionUnit) + fun unit(): Optional = Optional.ofNullable(unit) - fun newSubscriptionPackage(): Optional = - Optional.ofNullable(newSubscriptionPackage) + fun package_(): Optional = Optional.ofNullable(package_) - fun newSubscriptionMatrix(): Optional = - Optional.ofNullable(newSubscriptionMatrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun newSubscriptionTiered(): Optional = - Optional.ofNullable(newSubscriptionTiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun newSubscriptionTieredBps(): Optional = - Optional.ofNullable(newSubscriptionTieredBps) + fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - fun newSubscriptionBps(): Optional = - Optional.ofNullable(newSubscriptionBps) + fun bps(): Optional = Optional.ofNullable(bps) - fun newSubscriptionBulkBps(): Optional = - Optional.ofNullable(newSubscriptionBulkBps) + fun bulkBps(): Optional = Optional.ofNullable(bulkBps) - fun newSubscriptionBulk(): Optional = - Optional.ofNullable(newSubscriptionBulk) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun newSubscriptionThresholdTotalAmount(): - Optional = - Optional.ofNullable(newSubscriptionThresholdTotalAmount) + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) - fun newSubscriptionTieredPackage(): Optional = - Optional.ofNullable(newSubscriptionTieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun newSubscriptionTieredWithMinimum(): - Optional = - Optional.ofNullable(newSubscriptionTieredWithMinimum) + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) - fun newSubscriptionUnitWithPercent(): Optional = - Optional.ofNullable(newSubscriptionUnitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun newSubscriptionPackageWithAllocation(): - Optional = - Optional.ofNullable(newSubscriptionPackageWithAllocation) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) - fun newSubscriptionTierWithProration(): - Optional = - Optional.ofNullable(newSubscriptionTierWithProration) + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) - fun newSubscriptionUnitWithProration(): - Optional = - Optional.ofNullable(newSubscriptionUnitWithProration) + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) - fun newSubscriptionGroupedAllocation(): - Optional = - Optional.ofNullable(newSubscriptionGroupedAllocation) + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) - fun newSubscriptionGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithProratedMinimum) + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) - fun newSubscriptionBulkWithProration(): - Optional = - Optional.ofNullable(newSubscriptionBulkWithProration) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) - fun newSubscriptionScalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(newSubscriptionScalableMatrixWithUnitPricing) + fun scalableMatrixWithUnitPricing(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) - fun newSubscriptionScalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(newSubscriptionScalableMatrixWithTieredPricing) + fun scalableMatrixWithTieredPricing(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) - fun newSubscriptionCumulativeGroupedBulk(): - Optional = - Optional.ofNullable(newSubscriptionCumulativeGroupedBulk) + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) - fun newSubscriptionMaxGroupTieredPackage(): - Optional = - Optional.ofNullable(newSubscriptionMaxGroupTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) - fun newSubscriptionGroupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithMeteredMinimum) + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) - fun newSubscriptionMatrixWithDisplayName(): - Optional = - Optional.ofNullable(newSubscriptionMatrixWithDisplayName) + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) - fun newSubscriptionGroupedTieredPackage(): - Optional = - Optional.ofNullable(newSubscriptionGroupedTieredPackage) + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) - fun isNewSubscriptionUnit(): Boolean = newSubscriptionUnit != null + fun isUnit(): Boolean = unit != null - fun isNewSubscriptionPackage(): Boolean = newSubscriptionPackage != null + fun isPackage(): Boolean = package_ != null - fun isNewSubscriptionMatrix(): Boolean = newSubscriptionMatrix != null + fun isMatrix(): Boolean = matrix != null - fun isNewSubscriptionTiered(): Boolean = newSubscriptionTiered != null + fun isTiered(): Boolean = tiered != null - fun isNewSubscriptionTieredBps(): Boolean = newSubscriptionTieredBps != null + fun isTieredBps(): Boolean = tieredBps != null - fun isNewSubscriptionBps(): Boolean = newSubscriptionBps != null + fun isBps(): Boolean = bps != null - fun isNewSubscriptionBulkBps(): Boolean = newSubscriptionBulkBps != null + fun isBulkBps(): Boolean = bulkBps != null - fun isNewSubscriptionBulk(): Boolean = newSubscriptionBulk != null + fun isBulk(): Boolean = bulk != null - fun isNewSubscriptionThresholdTotalAmount(): Boolean = - newSubscriptionThresholdTotalAmount != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isNewSubscriptionTieredPackage(): Boolean = newSubscriptionTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null - fun isNewSubscriptionTieredWithMinimum(): Boolean = - newSubscriptionTieredWithMinimum != null + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isNewSubscriptionUnitWithPercent(): Boolean = newSubscriptionUnitWithPercent != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun isNewSubscriptionPackageWithAllocation(): Boolean = - newSubscriptionPackageWithAllocation != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun isNewSubscriptionTierWithProration(): Boolean = - newSubscriptionTierWithProration != null + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun isNewSubscriptionUnitWithProration(): Boolean = - newSubscriptionUnitWithProration != null + fun isUnitWithProration(): Boolean = unitWithProration != null - fun isNewSubscriptionGroupedAllocation(): Boolean = - newSubscriptionGroupedAllocation != null + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isNewSubscriptionGroupedWithProratedMinimum(): Boolean = - newSubscriptionGroupedWithProratedMinimum != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun isNewSubscriptionBulkWithProration(): Boolean = - newSubscriptionBulkWithProration != null + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isNewSubscriptionScalableMatrixWithUnitPricing(): Boolean = - newSubscriptionScalableMatrixWithUnitPricing != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isNewSubscriptionScalableMatrixWithTieredPricing(): Boolean = - newSubscriptionScalableMatrixWithTieredPricing != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isNewSubscriptionCumulativeGroupedBulk(): Boolean = - newSubscriptionCumulativeGroupedBulk != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isNewSubscriptionMaxGroupTieredPackage(): Boolean = - newSubscriptionMaxGroupTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isNewSubscriptionGroupedWithMeteredMinimum(): Boolean = - newSubscriptionGroupedWithMeteredMinimum != null + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isNewSubscriptionMatrixWithDisplayName(): Boolean = - newSubscriptionMatrixWithDisplayName != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isNewSubscriptionGroupedTieredPackage(): Boolean = - newSubscriptionGroupedTieredPackage != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun asNewSubscriptionUnit(): NewSubscriptionUnitPrice = - newSubscriptionUnit.getOrThrow("newSubscriptionUnit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asNewSubscriptionPackage(): NewSubscriptionPackagePrice = - newSubscriptionPackage.getOrThrow("newSubscriptionPackage") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asNewSubscriptionMatrix(): NewSubscriptionMatrixPrice = - newSubscriptionMatrix.getOrThrow("newSubscriptionMatrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asNewSubscriptionTiered(): NewSubscriptionTieredPrice = - newSubscriptionTiered.getOrThrow("newSubscriptionTiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asNewSubscriptionTieredBps(): NewSubscriptionTieredBpsPrice = - newSubscriptionTieredBps.getOrThrow("newSubscriptionTieredBps") + fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - fun asNewSubscriptionBps(): NewSubscriptionBpsPrice = - newSubscriptionBps.getOrThrow("newSubscriptionBps") + fun asBps(): Bps = bps.getOrThrow("bps") - fun asNewSubscriptionBulkBps(): NewSubscriptionBulkBpsPrice = - newSubscriptionBulkBps.getOrThrow("newSubscriptionBulkBps") + fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") - fun asNewSubscriptionBulk(): NewSubscriptionBulkPrice = - newSubscriptionBulk.getOrThrow("newSubscriptionBulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") - fun asNewSubscriptionThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - newSubscriptionThresholdTotalAmount.getOrThrow( - "newSubscriptionThresholdTotalAmount" - ) + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asNewSubscriptionTieredPackage(): NewSubscriptionTieredPackagePrice = - newSubscriptionTieredPackage.getOrThrow("newSubscriptionTieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asNewSubscriptionTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - newSubscriptionTieredWithMinimum.getOrThrow("newSubscriptionTieredWithMinimum") + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asNewSubscriptionUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - newSubscriptionUnitWithPercent.getOrThrow("newSubscriptionUnitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asNewSubscriptionPackageWithAllocation(): - NewSubscriptionPackageWithAllocationPrice = - newSubscriptionPackageWithAllocation.getOrThrow( - "newSubscriptionPackageWithAllocation" - ) + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") - fun asNewSubscriptionTierWithProration(): NewSubscriptionTierWithProrationPrice = - newSubscriptionTierWithProration.getOrThrow("newSubscriptionTierWithProration") + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") - fun asNewSubscriptionUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - newSubscriptionUnitWithProration.getOrThrow("newSubscriptionUnitWithProration") + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") - fun asNewSubscriptionGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - newSubscriptionGroupedAllocation.getOrThrow("newSubscriptionGroupedAllocation") + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") - fun asNewSubscriptionGroupedWithProratedMinimum(): - NewSubscriptionGroupedWithProratedMinimumPrice = - newSubscriptionGroupedWithProratedMinimum.getOrThrow( - "newSubscriptionGroupedWithProratedMinimum" - ) + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asNewSubscriptionBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - newSubscriptionBulkWithProration.getOrThrow("newSubscriptionBulkWithProration") + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") - fun asNewSubscriptionScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - newSubscriptionScalableMatrixWithUnitPricing.getOrThrow( - "newSubscriptionScalableMatrixWithUnitPricing" - ) + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asNewSubscriptionScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - newSubscriptionScalableMatrixWithTieredPricing.getOrThrow( - "newSubscriptionScalableMatrixWithTieredPricing" - ) + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asNewSubscriptionCumulativeGroupedBulk(): - NewSubscriptionCumulativeGroupedBulkPrice = - newSubscriptionCumulativeGroupedBulk.getOrThrow( - "newSubscriptionCumulativeGroupedBulk" - ) + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asNewSubscriptionMaxGroupTieredPackage(): - NewSubscriptionMaxGroupTieredPackagePrice = - newSubscriptionMaxGroupTieredPackage.getOrThrow( - "newSubscriptionMaxGroupTieredPackage" - ) + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asNewSubscriptionGroupedWithMeteredMinimum(): - NewSubscriptionGroupedWithMeteredMinimumPrice = - newSubscriptionGroupedWithMeteredMinimum.getOrThrow( - "newSubscriptionGroupedWithMeteredMinimum" - ) + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - fun asNewSubscriptionMatrixWithDisplayName(): - NewSubscriptionMatrixWithDisplayNamePrice = - newSubscriptionMatrixWithDisplayName.getOrThrow( - "newSubscriptionMatrixWithDisplayName" - ) + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asNewSubscriptionGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - newSubscriptionGroupedTieredPackage.getOrThrow( - "newSubscriptionGroupedTieredPackage" - ) + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newSubscriptionUnit != null -> - visitor.visitNewSubscriptionUnit(newSubscriptionUnit) - newSubscriptionPackage != null -> - visitor.visitNewSubscriptionPackage(newSubscriptionPackage) - newSubscriptionMatrix != null -> - visitor.visitNewSubscriptionMatrix(newSubscriptionMatrix) - newSubscriptionTiered != null -> - visitor.visitNewSubscriptionTiered(newSubscriptionTiered) - newSubscriptionTieredBps != null -> - visitor.visitNewSubscriptionTieredBps(newSubscriptionTieredBps) - newSubscriptionBps != null -> - visitor.visitNewSubscriptionBps(newSubscriptionBps) - newSubscriptionBulkBps != null -> - visitor.visitNewSubscriptionBulkBps(newSubscriptionBulkBps) - newSubscriptionBulk != null -> - visitor.visitNewSubscriptionBulk(newSubscriptionBulk) - newSubscriptionThresholdTotalAmount != null -> - visitor.visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount - ) - newSubscriptionTieredPackage != null -> - visitor.visitNewSubscriptionTieredPackage(newSubscriptionTieredPackage) - newSubscriptionTieredWithMinimum != null -> - visitor.visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum - ) - newSubscriptionUnitWithPercent != null -> - visitor.visitNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent) - newSubscriptionPackageWithAllocation != null -> - visitor.visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - newSubscriptionTierWithProration != null -> - visitor.visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration - ) - newSubscriptionUnitWithProration != null -> - visitor.visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration - ) - newSubscriptionGroupedAllocation != null -> - visitor.visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation - ) - newSubscriptionGroupedWithProratedMinimum != null -> - visitor.visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - newSubscriptionBulkWithProration != null -> - visitor.visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration - ) - newSubscriptionScalableMatrixWithUnitPricing != null -> - visitor.visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing - ) - newSubscriptionScalableMatrixWithTieredPricing != null -> - visitor.visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing - ) - newSubscriptionCumulativeGroupedBulk != null -> - visitor.visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk - ) - newSubscriptionMaxGroupTieredPackage != null -> - visitor.visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage - ) - newSubscriptionGroupedWithMeteredMinimum != null -> - visitor.visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum - ) - newSubscriptionMatrixWithDisplayName != null -> - visitor.visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName - ) - newSubscriptionGroupedTieredPackage != null -> - visitor.visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + tieredBps != null -> visitor.visitTieredBps(tieredBps) + bps != null -> visitor.visitBps(bps) + bulkBps != null -> visitor.visitBulkBps(bulkBps) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) else -> visitor.unknown(_json) } @@ -8682,165 +7769,127 @@ private constructor( } accept( - object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) { - newSubscriptionUnit.validate() + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() } - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) { - newSubscriptionPackage.validate() + override fun visitPackage(package_: Package) { + package_.validate() } - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) { - newSubscriptionMatrix.validate() + override fun visitMatrix(matrix: Matrix) { + matrix.validate() } - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) { - newSubscriptionTiered.validate() + override fun visitTiered(tiered: Tiered) { + tiered.validate() } - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) { - newSubscriptionTieredBps.validate() + override fun visitTieredBps(tieredBps: TieredBps) { + tieredBps.validate() } - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) { - newSubscriptionBps.validate() + override fun visitBps(bps: Bps) { + bps.validate() } - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) { - newSubscriptionBulkBps.validate() + override fun visitBulkBps(bulkBps: BulkBps) { + bulkBps.validate() } - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) { - newSubscriptionBulk.validate() + override fun visitBulk(bulk: Bulk) { + bulk.validate() } - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount ) { - newSubscriptionThresholdTotalAmount.validate() + thresholdTotalAmount.validate() } - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) { - newSubscriptionTieredPackage.validate() + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() } - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - newSubscriptionTieredWithMinimum.validate() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() } - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - newSubscriptionUnitWithPercent.validate() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() } - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation ) { - newSubscriptionPackageWithAllocation.validate() + packageWithAllocation.validate() } - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration ) { - newSubscriptionTierWithProration.validate() + tieredWithProration.validate() } - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - newSubscriptionUnitWithProration.validate() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() } - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - newSubscriptionGroupedAllocation.validate() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() } - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { - newSubscriptionGroupedWithProratedMinimum.validate() + groupedWithProratedMinimum.validate() } - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - newSubscriptionBulkWithProration.validate() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() } - override fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { - newSubscriptionScalableMatrixWithUnitPricing.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { - newSubscriptionScalableMatrixWithTieredPricing.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk ) { - newSubscriptionCumulativeGroupedBulk.validate() + cumulativeGroupedBulk.validate() } - override fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage ) { - newSubscriptionMaxGroupTieredPackage.validate() + maxGroupTieredPackage.validate() } - override fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { - newSubscriptionGroupedWithMeteredMinimum.validate() + groupedWithMeteredMinimum.validate() } - override fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName ) { - newSubscriptionMatrixWithDisplayName.validate() + matrixWithDisplayName.validate() } - override fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage ) { - newSubscriptionGroupedTieredPackage.validate() + groupedTieredPackage.validate() } } ) @@ -8865,115 +7914,83 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) = newSubscriptionUnit.validity() - - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) = newSubscriptionPackage.validity() - - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) = newSubscriptionMatrix.validity() - - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) = newSubscriptionTiered.validity() - - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = newSubscriptionTieredBps.validity() - - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) = newSubscriptionBps.validity() - - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) = newSubscriptionBulkBps.validity() - - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) = newSubscriptionBulk.validity() - - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice - ) = newSubscriptionThresholdTotalAmount.validity() - - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = newSubscriptionTieredPackage.validity() - - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = newSubscriptionTieredWithMinimum.validity() - - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = newSubscriptionUnitWithPercent.validity() - - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice - ) = newSubscriptionPackageWithAllocation.validity() - - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = newSubscriptionTierWithProration.validity() - - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = newSubscriptionUnitWithProration.validity() - - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = newSubscriptionGroupedAllocation.validity() - - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = newSubscriptionGroupedWithProratedMinimum.validity() - - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = newSubscriptionBulkWithProration.validity() - - override fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = newSubscriptionScalableMatrixWithUnitPricing.validity() - - override fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = newSubscriptionScalableMatrixWithTieredPricing.validity() - - override fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice - ) = newSubscriptionCumulativeGroupedBulk.validity() - - override fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice - ) = newSubscriptionMaxGroupTieredPackage.validity() - - override fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = newSubscriptionGroupedWithMeteredMinimum.validity() - - override fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice - ) = newSubscriptionMatrixWithDisplayName.validity() - - override fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice - ) = newSubscriptionGroupedTieredPackage.validity() + override fun 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 visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() + + override fun visitBulk(bulk: Bulk) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -8984,215 +8001,141 @@ private constructor( return true } - return /* spotless:off */ other is Price && newSubscriptionUnit == other.newSubscriptionUnit && newSubscriptionPackage == other.newSubscriptionPackage && newSubscriptionMatrix == other.newSubscriptionMatrix && newSubscriptionTiered == other.newSubscriptionTiered && newSubscriptionTieredBps == other.newSubscriptionTieredBps && newSubscriptionBps == other.newSubscriptionBps && newSubscriptionBulkBps == other.newSubscriptionBulkBps && newSubscriptionBulk == other.newSubscriptionBulk && newSubscriptionThresholdTotalAmount == other.newSubscriptionThresholdTotalAmount && newSubscriptionTieredPackage == other.newSubscriptionTieredPackage && newSubscriptionTieredWithMinimum == other.newSubscriptionTieredWithMinimum && newSubscriptionUnitWithPercent == other.newSubscriptionUnitWithPercent && newSubscriptionPackageWithAllocation == other.newSubscriptionPackageWithAllocation && newSubscriptionTierWithProration == other.newSubscriptionTierWithProration && newSubscriptionUnitWithProration == other.newSubscriptionUnitWithProration && newSubscriptionGroupedAllocation == other.newSubscriptionGroupedAllocation && newSubscriptionGroupedWithProratedMinimum == other.newSubscriptionGroupedWithProratedMinimum && newSubscriptionBulkWithProration == other.newSubscriptionBulkWithProration && newSubscriptionScalableMatrixWithUnitPricing == other.newSubscriptionScalableMatrixWithUnitPricing && newSubscriptionScalableMatrixWithTieredPricing == other.newSubscriptionScalableMatrixWithTieredPricing && newSubscriptionCumulativeGroupedBulk == other.newSubscriptionCumulativeGroupedBulk && newSubscriptionMaxGroupTieredPackage == other.newSubscriptionMaxGroupTieredPackage && newSubscriptionGroupedWithMeteredMinimum == other.newSubscriptionGroupedWithMeteredMinimum && newSubscriptionMatrixWithDisplayName == other.newSubscriptionMatrixWithDisplayName && newSubscriptionGroupedTieredPackage == other.newSubscriptionGroupedTieredPackage /* spotless:on */ + 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 /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newSubscriptionUnit, newSubscriptionPackage, newSubscriptionMatrix, newSubscriptionTiered, newSubscriptionTieredBps, newSubscriptionBps, newSubscriptionBulkBps, newSubscriptionBulk, newSubscriptionThresholdTotalAmount, newSubscriptionTieredPackage, newSubscriptionTieredWithMinimum, newSubscriptionUnitWithPercent, newSubscriptionPackageWithAllocation, newSubscriptionTierWithProration, newSubscriptionUnitWithProration, newSubscriptionGroupedAllocation, newSubscriptionGroupedWithProratedMinimum, newSubscriptionBulkWithProration, newSubscriptionScalableMatrixWithUnitPricing, newSubscriptionScalableMatrixWithTieredPricing, newSubscriptionCumulativeGroupedBulk, newSubscriptionMaxGroupTieredPackage, newSubscriptionGroupedWithMeteredMinimum, newSubscriptionMatrixWithDisplayName, newSubscriptionGroupedTieredPackage) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, bulkWithProration, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, maxGroupTieredPackage, groupedWithMeteredMinimum, matrixWithDisplayName, groupedTieredPackage) /* spotless:on */ override fun toString(): String = when { - newSubscriptionUnit != null -> "Price{newSubscriptionUnit=$newSubscriptionUnit}" - newSubscriptionPackage != null -> - "Price{newSubscriptionPackage=$newSubscriptionPackage}" - newSubscriptionMatrix != null -> - "Price{newSubscriptionMatrix=$newSubscriptionMatrix}" - newSubscriptionTiered != null -> - "Price{newSubscriptionTiered=$newSubscriptionTiered}" - newSubscriptionTieredBps != null -> - "Price{newSubscriptionTieredBps=$newSubscriptionTieredBps}" - newSubscriptionBps != null -> "Price{newSubscriptionBps=$newSubscriptionBps}" - newSubscriptionBulkBps != null -> - "Price{newSubscriptionBulkBps=$newSubscriptionBulkBps}" - newSubscriptionBulk != null -> "Price{newSubscriptionBulk=$newSubscriptionBulk}" - newSubscriptionThresholdTotalAmount != null -> - "Price{newSubscriptionThresholdTotalAmount=$newSubscriptionThresholdTotalAmount}" - newSubscriptionTieredPackage != null -> - "Price{newSubscriptionTieredPackage=$newSubscriptionTieredPackage}" - newSubscriptionTieredWithMinimum != null -> - "Price{newSubscriptionTieredWithMinimum=$newSubscriptionTieredWithMinimum}" - newSubscriptionUnitWithPercent != null -> - "Price{newSubscriptionUnitWithPercent=$newSubscriptionUnitWithPercent}" - newSubscriptionPackageWithAllocation != null -> - "Price{newSubscriptionPackageWithAllocation=$newSubscriptionPackageWithAllocation}" - newSubscriptionTierWithProration != null -> - "Price{newSubscriptionTierWithProration=$newSubscriptionTierWithProration}" - newSubscriptionUnitWithProration != null -> - "Price{newSubscriptionUnitWithProration=$newSubscriptionUnitWithProration}" - newSubscriptionGroupedAllocation != null -> - "Price{newSubscriptionGroupedAllocation=$newSubscriptionGroupedAllocation}" - newSubscriptionGroupedWithProratedMinimum != null -> - "Price{newSubscriptionGroupedWithProratedMinimum=$newSubscriptionGroupedWithProratedMinimum}" - newSubscriptionBulkWithProration != null -> - "Price{newSubscriptionBulkWithProration=$newSubscriptionBulkWithProration}" - newSubscriptionScalableMatrixWithUnitPricing != null -> - "Price{newSubscriptionScalableMatrixWithUnitPricing=$newSubscriptionScalableMatrixWithUnitPricing}" - newSubscriptionScalableMatrixWithTieredPricing != null -> - "Price{newSubscriptionScalableMatrixWithTieredPricing=$newSubscriptionScalableMatrixWithTieredPricing}" - newSubscriptionCumulativeGroupedBulk != null -> - "Price{newSubscriptionCumulativeGroupedBulk=$newSubscriptionCumulativeGroupedBulk}" - newSubscriptionMaxGroupTieredPackage != null -> - "Price{newSubscriptionMaxGroupTieredPackage=$newSubscriptionMaxGroupTieredPackage}" - newSubscriptionGroupedWithMeteredMinimum != null -> - "Price{newSubscriptionGroupedWithMeteredMinimum=$newSubscriptionGroupedWithMeteredMinimum}" - newSubscriptionMatrixWithDisplayName != null -> - "Price{newSubscriptionMatrixWithDisplayName=$newSubscriptionMatrixWithDisplayName}" - newSubscriptionGroupedTieredPackage != null -> - "Price{newSubscriptionGroupedTieredPackage=$newSubscriptionGroupedTieredPackage}" + 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}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } companion object { + @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 ofBulkBps(bulkBps: BulkBps) = Price(bulkBps = bulkBps) + + @JvmStatic fun ofBulk(bulk: Bulk) = Price(bulk = bulk) + @JvmStatic - fun ofNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice) = - Price(newSubscriptionUnit = newSubscriptionUnit) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + Price(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofNewSubscriptionPackage(newSubscriptionPackage: NewSubscriptionPackagePrice) = - Price(newSubscriptionPackage = newSubscriptionPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + Price(tieredPackage = tieredPackage) @JvmStatic - fun ofNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice) = - Price(newSubscriptionMatrix = newSubscriptionMatrix) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice) = - Price(newSubscriptionTiered = newSubscriptionTiered) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + Price(unitWithPercent = unitWithPercent) @JvmStatic - fun ofNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = Price(newSubscriptionTieredBps = newSubscriptionTieredBps) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice) = - Price(newSubscriptionBps = newSubscriptionBps) + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) @JvmStatic - fun ofNewSubscriptionBulkBps(newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice) = - Price(newSubscriptionBulkBps = newSubscriptionBulkBps) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + Price(unitWithProration = unitWithProration) @JvmStatic - fun ofNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice) = - Price(newSubscriptionBulk = newSubscriptionBulk) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + Price(groupedAllocation = groupedAllocation) @JvmStatic - fun ofNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(newSubscriptionThresholdTotalAmount = newSubscriptionThresholdTotalAmount) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = Price(newSubscriptionTieredPackage = newSubscriptionTieredPackage) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + Price(bulkWithProration = bulkWithProration) @JvmStatic - fun ofNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = Price(newSubscriptionTieredWithMinimum = newSubscriptionTieredWithMinimum) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic - fun ofNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = Price(newSubscriptionUnitWithPercent = newSubscriptionUnitWithPercent) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = - Price( - newSubscriptionPackageWithAllocation = newSubscriptionPackageWithAllocation - ) - - @JvmStatic - fun ofNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(newSubscriptionTierWithProration = newSubscriptionTierWithProration) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + Price(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic - fun ofNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = Price(newSubscriptionUnitWithProration = newSubscriptionUnitWithProration) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + Price(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic - fun ofNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = Price(newSubscriptionGroupedAllocation = newSubscriptionGroupedAllocation) + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = - Price( - newSubscriptionGroupedWithProratedMinimum = - newSubscriptionGroupedWithProratedMinimum - ) - - @JvmStatic - fun ofNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = Price(newSubscriptionBulkWithProration = newSubscriptionBulkWithProration) - - @JvmStatic - fun ofNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = - Price( - newSubscriptionScalableMatrixWithUnitPricing = - newSubscriptionScalableMatrixWithUnitPricing - ) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = - Price( - newSubscriptionScalableMatrixWithTieredPricing = - newSubscriptionScalableMatrixWithTieredPricing - ) - - @JvmStatic - fun ofNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = - Price( - newSubscriptionCumulativeGroupedBulk = newSubscriptionCumulativeGroupedBulk - ) - - @JvmStatic - fun ofNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = - Price( - newSubscriptionMaxGroupTieredPackage = newSubscriptionMaxGroupTieredPackage - ) - - @JvmStatic - fun ofNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = - Price( - newSubscriptionGroupedWithMeteredMinimum = - newSubscriptionGroupedWithMeteredMinimum - ) - - @JvmStatic - fun ofNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = - Price( - newSubscriptionMatrixWithDisplayName = newSubscriptionMatrixWithDisplayName - ) - - @JvmStatic - fun ofNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(newSubscriptionGroupedTieredPackage = newSubscriptionGroupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + Price(groupedTieredPackage = groupedTieredPackage) } /** @@ -9200,99 +8143,63 @@ private constructor( */ interface Visitor { - fun visitNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ): T + fun visitPackage(package_: Package): T - fun visitNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ): T + fun visitTieredBps(tieredBps: TieredBps): T - fun visitNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice): T + fun visitBps(bps: Bps): T - fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ): T + fun visitBulkBps(bulkBps: BulkBps): T - fun visitNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice): T + fun visitBulk(bulk: Bulk): T - fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T - fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T - fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T - fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T - fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T - fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T - fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -9318,221 +8225,138 @@ private constructor( when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionUnit = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(package_ = it, _json = json) + } ?: Price(_json = json) } "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionMatrix = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) } "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } "tiered_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredBps = it, _json = json) + } ?: Price(_json = json) } "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bps = it, _json = json) + } ?: Price(_json = json) } "bulk_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionBulkBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkBps = it, _json = json) + } ?: Price(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionThresholdTotalAmount = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) } "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredPackage = it, _json = json) + } ?: Price(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredWithMinimum = it, _json = json) + } ?: Price(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionUnitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithPercent = it, _json = json) + } ?: Price(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionPackageWithAllocation = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) } "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTierWithProration = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionUnitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedAllocation = it, _json = json) + } ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionBulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithProration = it, _json = json) + } ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionScalableMatrixWithUnitPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionScalableMatrixWithTieredPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionCumulativeGroupedBulk = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionMaxGroupTieredPackage = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price( - newSubscriptionGroupedWithMeteredMinimum = it, - _json = json, - ) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionMatrixWithDisplayName = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionGroupedTieredPackage = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } } @@ -9548,71 +8372,58 @@ private constructor( provider: SerializerProvider, ) { when { - value.newSubscriptionUnit != null -> - generator.writeObject(value.newSubscriptionUnit) - value.newSubscriptionPackage != null -> - generator.writeObject(value.newSubscriptionPackage) - value.newSubscriptionMatrix != null -> - generator.writeObject(value.newSubscriptionMatrix) - value.newSubscriptionTiered != null -> - generator.writeObject(value.newSubscriptionTiered) - value.newSubscriptionTieredBps != null -> - generator.writeObject(value.newSubscriptionTieredBps) - value.newSubscriptionBps != null -> - generator.writeObject(value.newSubscriptionBps) - value.newSubscriptionBulkBps != null -> - generator.writeObject(value.newSubscriptionBulkBps) - value.newSubscriptionBulk != null -> - generator.writeObject(value.newSubscriptionBulk) - value.newSubscriptionThresholdTotalAmount != null -> - generator.writeObject(value.newSubscriptionThresholdTotalAmount) - value.newSubscriptionTieredPackage != null -> - generator.writeObject(value.newSubscriptionTieredPackage) - value.newSubscriptionTieredWithMinimum != null -> - generator.writeObject(value.newSubscriptionTieredWithMinimum) - value.newSubscriptionUnitWithPercent != null -> - generator.writeObject(value.newSubscriptionUnitWithPercent) - value.newSubscriptionPackageWithAllocation != null -> - generator.writeObject(value.newSubscriptionPackageWithAllocation) - value.newSubscriptionTierWithProration != null -> - generator.writeObject(value.newSubscriptionTierWithProration) - value.newSubscriptionUnitWithProration != null -> - generator.writeObject(value.newSubscriptionUnitWithProration) - value.newSubscriptionGroupedAllocation != null -> - generator.writeObject(value.newSubscriptionGroupedAllocation) - value.newSubscriptionGroupedWithProratedMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithProratedMinimum) - value.newSubscriptionBulkWithProration != null -> - generator.writeObject(value.newSubscriptionBulkWithProration) - value.newSubscriptionScalableMatrixWithUnitPricing != null -> - generator.writeObject( - value.newSubscriptionScalableMatrixWithUnitPricing - ) - value.newSubscriptionScalableMatrixWithTieredPricing != null -> - generator.writeObject( - value.newSubscriptionScalableMatrixWithTieredPricing - ) - value.newSubscriptionCumulativeGroupedBulk != null -> - generator.writeObject(value.newSubscriptionCumulativeGroupedBulk) - value.newSubscriptionMaxGroupTieredPackage != null -> - generator.writeObject(value.newSubscriptionMaxGroupTieredPackage) - value.newSubscriptionGroupedWithMeteredMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithMeteredMinimum) - value.newSubscriptionMatrixWithDisplayName != null -> - generator.writeObject(value.newSubscriptionMatrixWithDisplayName) - value.newSubscriptionGroupedTieredPackage != null -> - generator.writeObject(value.newSubscriptionGroupedTieredPackage) + 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._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - class NewSubscriptionUnitPrice + class Unit private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitConfig: JsonField, private val billableMetricId: JsonField, @@ -9639,7 +8450,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -9720,11 +8531,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -9865,16 +8680,6 @@ private constructor( */ @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]. * @@ -10020,14 +8825,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitPrice]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` @@ -10035,12 +8838,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitPrice]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -10060,27 +8863,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionUnitPrice: NewSubscriptionUnitPrice) = apply { - cadence = newSubscriptionUnitPrice.cadence - itemId = newSubscriptionUnitPrice.itemId - modelType = newSubscriptionUnitPrice.modelType - name = newSubscriptionUnitPrice.name - unitConfig = newSubscriptionUnitPrice.unitConfig - billableMetricId = newSubscriptionUnitPrice.billableMetricId - billedInAdvance = newSubscriptionUnitPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitPrice.conversionRate - currency = newSubscriptionUnitPrice.currency - externalPriceId = newSubscriptionUnitPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitPrice.metadata - referenceId = newSubscriptionUnitPrice.referenceId - additionalProperties = - newSubscriptionUnitPrice.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + currency = unit.currency + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -10107,18 +8907,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -10452,7 +9253,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitPrice]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -10460,18 +9261,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitPrice = - NewSubscriptionUnitPrice( + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitConfig", unitConfig), billableMetricId, @@ -10491,14 +9291,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitPrice = apply { + fun validate(): Unit = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitConfig().validate() billableMetricId() @@ -10533,7 +9337,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -10707,135 +9511,6 @@ private constructor( 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 UNIT = of("unit") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT - } - - /** - * 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 { - UNIT, - /** - * 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) { - UNIT -> Value.UNIT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT -> Known.UNIT - 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 UnitConfig private constructor( private val unitAmount: JsonField, @@ -11845,7 +10520,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Unit && 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 && currency == other.currency && 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 */ @@ -11855,14 +10530,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionPackagePrice + class Package private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageConfig: JsonField, private val billableMetricId: JsonField, @@ -11889,7 +10564,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -11970,11 +10645,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -12115,16 +10794,6 @@ private constructor( */ @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]. * @@ -12270,14 +10939,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionPackagePrice]. + * Returns a mutable builder for constructing an instance of [Package]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` @@ -12285,12 +10952,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionPackagePrice]. */ + /** A builder for [Package]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package") private var name: JsonField? = null private var packageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -12310,29 +10977,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionPackagePrice: NewSubscriptionPackagePrice) = - apply { - cadence = newSubscriptionPackagePrice.cadence - itemId = newSubscriptionPackagePrice.itemId - modelType = newSubscriptionPackagePrice.modelType - name = newSubscriptionPackagePrice.name - packageConfig = newSubscriptionPackagePrice.packageConfig - billableMetricId = newSubscriptionPackagePrice.billableMetricId - billedInAdvance = newSubscriptionPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionPackagePrice.conversionRate - currency = newSubscriptionPackagePrice.currency - externalPriceId = newSubscriptionPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionPackagePrice.metadata - referenceId = newSubscriptionPackagePrice.referenceId - additionalProperties = - newSubscriptionPackagePrice.additionalProperties.toMutableMap() - } + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + currency = package_.currency + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -12358,18 +11021,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -12704,7 +11368,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionPackagePrice]. + * Returns an immutable instance of [Package]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -12712,18 +11376,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionPackagePrice = - NewSubscriptionPackagePrice( + fun build(): Package = + Package( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageConfig", packageConfig), billableMetricId, @@ -12743,14 +11406,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionPackagePrice = apply { + fun validate(): Package = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageConfig().validate() billableMetricId() @@ -12785,7 +11452,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -12959,135 +11626,6 @@ private constructor( 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 PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * 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 { - PACKAGE, - /** - * 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) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - 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 PackageConfig private constructor( private val packageAmount: JsonField, @@ -14148,7 +12686,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Package && 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 && currency == other.currency && 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 */ @@ -14158,15 +12696,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Package{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMatrixPrice + class Matrix private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -14195,7 +12733,7 @@ private constructor( matrixConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -14280,11 +12818,15 @@ private constructor( fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -14428,16 +12970,6 @@ private constructor( @ExcludeMissing fun _matrixConfig(): JsonField = matrixConfig - /** - * 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]. * @@ -14573,28 +13105,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMatrixPrice]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMatrixPrice]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -14613,29 +13143,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionMatrixPrice: NewSubscriptionMatrixPrice) = - apply { - cadence = newSubscriptionMatrixPrice.cadence - itemId = newSubscriptionMatrixPrice.itemId - matrixConfig = newSubscriptionMatrixPrice.matrixConfig - modelType = newSubscriptionMatrixPrice.modelType - name = newSubscriptionMatrixPrice.name - billableMetricId = newSubscriptionMatrixPrice.billableMetricId - billedInAdvance = newSubscriptionMatrixPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixPrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixPrice.conversionRate - currency = newSubscriptionMatrixPrice.currency - externalPriceId = newSubscriptionMatrixPrice.externalPriceId - fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionMatrixPrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixPrice.metadata - referenceId = newSubscriptionMatrixPrice.referenceId - additionalProperties = - newSubscriptionMatrixPrice.additionalProperties.toMutableMap() - } + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + currency = matrix.currency + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -14675,18 +13201,19 @@ private constructor( this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -15007,7 +13534,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMatrixPrice]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -15016,18 +13543,17 @@ private constructor( * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMatrixPrice = - NewSubscriptionMatrixPrice( + fun build(): Matrix = + Matrix( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -15046,7 +13572,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMatrixPrice = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -15054,7 +13580,11 @@ private constructor( cadence().validate() itemId() matrixConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -15089,7 +13619,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -15807,135 +14337,6 @@ private constructor( "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -16774,7 +15175,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Matrix && 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 && currency == other.currency && 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 */ @@ -16784,14 +15185,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Matrix{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredPrice + class Tiered private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredConfig: JsonField, private val billableMetricId: JsonField, @@ -16818,7 +15219,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -16899,11 +15300,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -17044,16 +15449,6 @@ private constructor( */ @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]. * @@ -17199,14 +15594,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredPrice]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` @@ -17214,12 +15607,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredPrice]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered") private var name: JsonField? = null private var tieredConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -17239,29 +15632,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionTieredPrice: NewSubscriptionTieredPrice) = - apply { - cadence = newSubscriptionTieredPrice.cadence - itemId = newSubscriptionTieredPrice.itemId - modelType = newSubscriptionTieredPrice.modelType - name = newSubscriptionTieredPrice.name - tieredConfig = newSubscriptionTieredPrice.tieredConfig - billableMetricId = newSubscriptionTieredPrice.billableMetricId - billedInAdvance = newSubscriptionTieredPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPrice.conversionRate - currency = newSubscriptionTieredPrice.currency - externalPriceId = newSubscriptionTieredPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPrice.metadata - referenceId = newSubscriptionTieredPrice.referenceId - additionalProperties = - newSubscriptionTieredPrice.additionalProperties.toMutableMap() - } + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + currency = tiered.currency + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -17287,18 +15676,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -17633,7 +16023,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredPrice]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -17641,18 +16031,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredPrice = - NewSubscriptionTieredPrice( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredConfig", tieredConfig), billableMetricId, @@ -17672,14 +16061,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredPrice = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredConfig().validate() billableMetricId() @@ -17714,7 +16107,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -17888,135 +16281,6 @@ private constructor( 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 = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * 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, - /** - * 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 -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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 -> Known.TIERED - 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 TieredConfig private constructor( private val tiers: JsonField>, @@ -19318,7 +17582,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tiered && 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 && currency == other.currency && 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 */ @@ -19328,14 +17592,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredBpsPrice + class TieredBps private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredBpsConfig: JsonField, private val billableMetricId: JsonField, @@ -19362,7 +17626,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -19443,11 +17707,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -19589,16 +17857,6 @@ private constructor( */ @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]. * @@ -19744,14 +18002,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredBpsPrice]. + * Returns a mutable builder for constructing an instance of [TieredBps]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` @@ -19759,12 +18015,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredBpsPrice]. */ + /** A builder for [TieredBps]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_bps") private var name: JsonField? = null private var tieredBpsConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -19784,29 +18040,24 @@ private constructor( 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 - currency = newSubscriptionTieredBpsPrice.currency - externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredBpsPrice.metadata - referenceId = newSubscriptionTieredBpsPrice.referenceId - additionalProperties = - newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() + internal fun from(tieredBps: TieredBps) = apply { + cadence = tieredBps.cadence + itemId = tieredBps.itemId + modelType = tieredBps.modelType + name = tieredBps.name + tieredBpsConfig = tieredBps.tieredBpsConfig + billableMetricId = tieredBps.billableMetricId + billedInAdvance = tieredBps.billedInAdvance + billingCycleConfiguration = tieredBps.billingCycleConfiguration + conversionRate = tieredBps.conversionRate + currency = tieredBps.currency + externalPriceId = tieredBps.externalPriceId + fixedPriceQuantity = tieredBps.fixedPriceQuantity + invoiceGroupingKey = tieredBps.invoiceGroupingKey + invoicingCycleConfiguration = tieredBps.invoicingCycleConfiguration + metadata = tieredBps.metadata + referenceId = tieredBps.referenceId + additionalProperties = tieredBps.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -19833,18 +18084,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -20179,7 +18431,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredBpsPrice]. + * Returns an immutable instance of [TieredBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -20187,18 +18439,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice( + fun build(): TieredBps = + TieredBps( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredBpsConfig", tieredBpsConfig), billableMetricId, @@ -20218,14 +18469,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredBpsPrice = apply { + fun validate(): TieredBps = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredBpsConfig().validate() billableMetricId() @@ -20260,7 +18515,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -20434,135 +18689,6 @@ private constructor( 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() - } - class TieredBpsConfig private constructor( private val tiers: JsonField>, @@ -21906,7 +20032,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBps && 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 && currency == other.currency && 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 */ @@ -21916,15 +20042,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredBps{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBpsPrice + class Bps private constructor( private val bpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -21953,7 +20079,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -22038,11 +20164,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -22186,16 +20316,6 @@ private constructor( */ @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]. * @@ -22331,28 +20451,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBpsPrice]. + * Returns a mutable builder for constructing an instance of [Bps]. * * The following fields are required: * ```java * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBpsPrice]. */ + /** A builder for [Bps]. */ 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 modelType: JsonValue = JsonValue.from("bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -22371,27 +20489,24 @@ private constructor( 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 - currency = newSubscriptionBpsPrice.currency - externalPriceId = newSubscriptionBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBpsPrice.metadata - referenceId = newSubscriptionBpsPrice.referenceId - additionalProperties = - newSubscriptionBpsPrice.additionalProperties.toMutableMap() + internal fun from(bps: Bps) = apply { + bpsConfig = bps.bpsConfig + cadence = bps.cadence + itemId = bps.itemId + modelType = bps.modelType + name = bps.name + billableMetricId = bps.billableMetricId + billedInAdvance = bps.billedInAdvance + billingCycleConfiguration = bps.billingCycleConfiguration + conversionRate = bps.conversionRate + currency = bps.currency + externalPriceId = bps.externalPriceId + fixedPriceQuantity = bps.fixedPriceQuantity + invoiceGroupingKey = bps.invoiceGroupingKey + invoicingCycleConfiguration = bps.invoicingCycleConfiguration + metadata = bps.metadata + referenceId = bps.referenceId + additionalProperties = bps.additionalProperties.toMutableMap() } fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) @@ -22431,18 +20546,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -22763,7 +20879,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBpsPrice]. + * Returns an immutable instance of [Bps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -22772,18 +20888,17 @@ private constructor( * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBpsPrice = - NewSubscriptionBpsPrice( + fun build(): Bps = + Bps( checkRequired("bpsConfig", bpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -22802,7 +20917,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBpsPrice = apply { + fun validate(): Bps = apply { if (validated) { return@apply } @@ -22810,7 +20925,11 @@ private constructor( bpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -22845,7 +20964,7 @@ private constructor( (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -23236,135 +21355,6 @@ private constructor( 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -24203,7 +22193,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bps && 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 && currency == other.currency && 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 */ @@ -24213,15 +22203,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bps{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkBpsPrice + class BulkBps private constructor( private val bulkBpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -24250,7 +22240,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -24335,11 +22325,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -24483,16 +22477,6 @@ private constructor( */ @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]. * @@ -24628,28 +22612,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of [BulkBps]. * * The following fields are required: * ```java * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkBpsPrice]. */ + /** A builder for [BulkBps]. */ class Builder internal constructor() { private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -24668,29 +22650,25 @@ 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 - currency = newSubscriptionBulkBpsPrice.currency - externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkBpsPrice.metadata - referenceId = newSubscriptionBulkBpsPrice.referenceId - additionalProperties = - newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() - } + internal fun from(bulkBps: BulkBps) = apply { + bulkBpsConfig = bulkBps.bulkBpsConfig + cadence = bulkBps.cadence + itemId = bulkBps.itemId + modelType = bulkBps.modelType + name = bulkBps.name + billableMetricId = bulkBps.billableMetricId + billedInAdvance = bulkBps.billedInAdvance + billingCycleConfiguration = bulkBps.billingCycleConfiguration + conversionRate = bulkBps.conversionRate + currency = bulkBps.currency + externalPriceId = bulkBps.externalPriceId + fixedPriceQuantity = bulkBps.fixedPriceQuantity + invoiceGroupingKey = bulkBps.invoiceGroupingKey + invoicingCycleConfiguration = bulkBps.invoicingCycleConfiguration + metadata = bulkBps.metadata + referenceId = bulkBps.referenceId + additionalProperties = bulkBps.additionalProperties.toMutableMap() + } fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = bulkBpsConfig(JsonField.of(bulkBpsConfig)) @@ -24730,18 +22708,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -25062,7 +23041,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkBpsPrice]. + * Returns an immutable instance of [BulkBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -25071,18 +23050,17 @@ private constructor( * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( + fun build(): BulkBps = + BulkBps( checkRequired("bulkBpsConfig", bulkBpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -25101,7 +23079,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkBpsPrice = apply { + fun validate(): BulkBps = apply { if (validated) { return@apply } @@ -25109,7 +23087,11 @@ private constructor( bulkBpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -25144,7 +23126,7 @@ private constructor( (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -25776,135 +23758,6 @@ private constructor( 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 BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -26743,7 +24596,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBps && 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 && currency == other.currency && 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 */ @@ -26753,15 +24606,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkBps{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkPrice + class Bulk private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -26790,7 +24643,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -26875,11 +24728,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -27023,16 +24880,6 @@ private constructor( */ @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]. * @@ -27168,28 +25015,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkPrice]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkPrice]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -27208,27 +25053,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionBulkPrice: NewSubscriptionBulkPrice) = apply { - bulkConfig = newSubscriptionBulkPrice.bulkConfig - cadence = newSubscriptionBulkPrice.cadence - itemId = newSubscriptionBulkPrice.itemId - modelType = newSubscriptionBulkPrice.modelType - name = newSubscriptionBulkPrice.name - billableMetricId = newSubscriptionBulkPrice.billableMetricId - billedInAdvance = newSubscriptionBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkPrice.conversionRate - currency = newSubscriptionBulkPrice.currency - externalPriceId = newSubscriptionBulkPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkPrice.metadata - referenceId = newSubscriptionBulkPrice.referenceId - additionalProperties = - newSubscriptionBulkPrice.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + currency = bulk.currency + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() } fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) @@ -27268,18 +25110,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -27600,7 +25443,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkPrice]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -27609,18 +25452,17 @@ private constructor( * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkPrice = - NewSubscriptionBulkPrice( + fun build(): Bulk = + Bulk( checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -27639,7 +25481,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkPrice = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -27647,7 +25489,11 @@ private constructor( bulkConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -27682,7 +25528,7 @@ private constructor( (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -28272,135 +26118,6 @@ private constructor( 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 BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -29239,7 +26956,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bulk && 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 && currency == other.currency && 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 */ @@ -29249,14 +26966,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionThresholdTotalAmountPrice + class ThresholdTotalAmount private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val thresholdTotalAmountConfig: JsonField, private val billableMetricId: JsonField, @@ -29283,7 +27000,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -29365,11 +27082,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -29511,16 +27232,6 @@ private constructor( */ @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]. * @@ -29668,13 +27379,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionThresholdTotalAmountPrice]. + * [ThresholdTotalAmount]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` @@ -29682,12 +27392,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionThresholdTotalAmountPrice]. */ + /** A builder for [ThresholdTotalAmount]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") private var name: JsonField? = null private var thresholdTotalAmountConfig: JsonField? = null @@ -29708,34 +27418,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionThresholdTotalAmountPrice: - NewSubscriptionThresholdTotalAmountPrice - ) = apply { - cadence = newSubscriptionThresholdTotalAmountPrice.cadence - itemId = newSubscriptionThresholdTotalAmountPrice.itemId - modelType = newSubscriptionThresholdTotalAmountPrice.modelType - name = newSubscriptionThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newSubscriptionThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newSubscriptionThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newSubscriptionThresholdTotalAmountPrice.conversionRate - currency = newSubscriptionThresholdTotalAmountPrice.currency - externalPriceId = newSubscriptionThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + currency = thresholdTotalAmount.currency + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newSubscriptionThresholdTotalAmountPrice.metadata - referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId + thresholdTotalAmount.invoicingCycleConfiguration + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId additionalProperties = - newSubscriptionThresholdTotalAmountPrice.additionalProperties - .toMutableMap() + thresholdTotalAmount.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -29762,18 +27464,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -30110,7 +27813,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionThresholdTotalAmountPrice]. + * Returns an immutable instance of [ThresholdTotalAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -30118,18 +27821,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionThresholdTotalAmountPrice = - NewSubscriptionThresholdTotalAmountPrice( + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), billableMetricId, @@ -30149,14 +27851,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -30191,7 +27897,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -30365,135 +28073,6 @@ private constructor( 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 THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * 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 { - THRESHOLD_TOTAL_AMOUNT, - /** - * 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) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - 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 ThresholdTotalAmountConfig @JsonCreator private constructor( @@ -31446,7 +29025,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmount && 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 && currency == other.currency && 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 */ @@ -31456,14 +29035,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredPackagePrice + class TieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredPackageConfig: JsonField, private val billableMetricId: JsonField, @@ -31490,7 +29069,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -31571,11 +29150,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -31717,16 +29300,6 @@ private constructor( */ @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]. * @@ -31872,14 +29445,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [TieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` @@ -31887,12 +29458,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredPackagePrice]. */ + /** A builder for [TieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_package") private var name: JsonField? = null private var tieredPackageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -31912,29 +29483,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionTieredPackagePrice: NewSubscriptionTieredPackagePrice - ) = apply { - cadence = newSubscriptionTieredPackagePrice.cadence - itemId = newSubscriptionTieredPackagePrice.itemId - modelType = newSubscriptionTieredPackagePrice.modelType - name = newSubscriptionTieredPackagePrice.name - tieredPackageConfig = newSubscriptionTieredPackagePrice.tieredPackageConfig - billableMetricId = newSubscriptionTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPackagePrice.conversionRate - currency = newSubscriptionTieredPackagePrice.currency - externalPriceId = newSubscriptionTieredPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPackagePrice.metadata - referenceId = newSubscriptionTieredPackagePrice.referenceId - additionalProperties = - newSubscriptionTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + currency = tieredPackage.currency + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -31961,18 +29527,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -32308,7 +29875,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredPackagePrice]. + * Returns an immutable instance of [TieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -32316,18 +29883,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredPackagePrice = - NewSubscriptionTieredPackagePrice( + fun build(): TieredPackage = + TieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredPackageConfig", tieredPackageConfig), billableMetricId, @@ -32347,14 +29913,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredPackagePrice = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredPackageConfig().validate() billableMetricId() @@ -32389,7 +29959,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -32563,102 +30133,78 @@ private constructor( override fun toString() = value.toString() } - class ModelType + class TieredPackageConfig @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ + private constructor( @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + private val additionalProperties: Map + ) { - @JvmField val TIERED_PACKAGE = of("tiered_package") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } + fun toBuilder() = Builder().from(this) - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } + companion object { - /** - * 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_PACKAGE, /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. + * Returns a mutable builder for constructing an instance of + * [TieredPackageConfig]. */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + 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) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig(additionalProperties.toImmutable()) + } + private var validated: Boolean = false - fun validate(): ModelType = apply { + fun validate(): TieredPackageConfig = apply { if (validated) { return@apply } - known() validated = true } @@ -32677,31 +30223,97 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode() = value.hashCode() + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{additionalProperties=$additionalProperties}" } - class TieredPackageConfig - @JsonCreator + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + class BillingCycleConfiguration private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val duration: JsonField, + private val durationUnit: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + durationUnit: JsonField = JsonMissing.of(), + ) : this(duration, durationUnit, mutableMapOf()) + + /** + * The duration of the billing 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 duration(): Long = duration.getRequired("duration") + + /** + * The unit of billing period duration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [durationUnit]. + * + * Unlike [durationUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit + + @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) @@ -32709,230 +30321,59 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredPackageConfig]. + * [BillingCycleConfiguration]. + * + * The following fields are required: + * ```java + * .duration() + * .durationUnit() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredPackageConfig]. */ + /** A builder for [BillingCycleConfiguration]. */ class Builder internal constructor() { + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredPackageConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @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 TieredPackageConfig && 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() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - class BillingCycleConfiguration - private constructor( - private val duration: JsonField, - private val durationUnit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - durationUnit: JsonField = JsonMissing.of(), - ) : this(duration, durationUnit, mutableMapOf()) - - /** - * The duration of the billing 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 duration(): Long = duration.getRequired("duration") - - /** - * The unit of billing period duration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** - * Returns the raw JSON value of [durationUnit]. - * - * Unlike [durationUnit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BillingCycleConfiguration]. - * - * The following fields are required: - * ```java - * .duration() - * .durationUnit() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** - * Sets [Builder.durationUnit] to an arbitrary JSON value. - * - * You should usually call [Builder.durationUnit] with a well-typed - * [DurationUnit] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = + apply { + duration = billingCycleConfiguration.duration + durationUnit = billingCycleConfiguration.durationUnit + additionalProperties = + billingCycleConfiguration.additionalProperties.toMutableMap() + } + + /** The duration of the billing period. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** + * Sets [Builder.durationUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.durationUnit] with a well-typed + * [DurationUnit] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit } fun additionalProperties(additionalProperties: Map) = @@ -33643,7 +31084,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackage && 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 && currency == other.currency && 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 */ @@ -33653,14 +31094,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredPackage{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredWithMinimumPrice + class TieredWithMinimum private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithMinimumConfig: JsonField, private val billableMetricId: JsonField, @@ -33687,7 +31128,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -33768,11 +31209,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -33914,16 +31359,6 @@ private constructor( */ @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]. * @@ -34071,13 +31506,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredWithMinimumPrice]. + * [TieredWithMinimum]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` @@ -34085,12 +31519,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredWithMinimumPrice]. */ + /** A builder for [TieredWithMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var tieredWithMinimumConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -34110,33 +31544,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionTieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice - ) = apply { - cadence = newSubscriptionTieredWithMinimumPrice.cadence - itemId = newSubscriptionTieredWithMinimumPrice.itemId - modelType = newSubscriptionTieredWithMinimumPrice.modelType - name = newSubscriptionTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newSubscriptionTieredWithMinimumPrice.billableMetricId - billedInAdvance = newSubscriptionTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredWithMinimumPrice.conversionRate - currency = newSubscriptionTieredWithMinimumPrice.currency - externalPriceId = newSubscriptionTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredWithMinimumPrice.metadata - referenceId = newSubscriptionTieredWithMinimumPrice.referenceId - additionalProperties = - newSubscriptionTieredWithMinimumPrice.additionalProperties - .toMutableMap() + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + currency = tieredWithMinimum.currency + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -34163,18 +31588,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -34509,7 +31935,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredWithMinimumPrice]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -34517,18 +31943,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredWithMinimumPrice = - NewSubscriptionTieredWithMinimumPrice( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), billableMetricId, @@ -34548,14 +31973,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithMinimumConfig().validate() billableMetricId() @@ -34590,7 +32019,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -34764,135 +32195,6 @@ private constructor( 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_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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 TieredWithMinimumConfig @JsonCreator private constructor( @@ -35845,7 +33147,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithMinimum && 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 && currency == other.currency && 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 */ @@ -35855,14 +33157,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionUnitWithPercentPrice + class UnitWithPercent private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithPercentConfig: JsonField, private val billableMetricId: JsonField, @@ -35889,7 +33191,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -35970,11 +33272,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -36116,16 +33422,6 @@ private constructor( */ @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]. * @@ -36272,14 +33568,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitWithPercentPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` @@ -36287,12 +33581,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitWithPercentPrice]. */ + /** A builder for [UnitWithPercent]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") private var name: JsonField? = null private var unitWithPercentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -36312,30 +33606,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionUnitWithPercentPrice: NewSubscriptionUnitWithPercentPrice - ) = apply { - cadence = newSubscriptionUnitWithPercentPrice.cadence - itemId = newSubscriptionUnitWithPercentPrice.itemId - modelType = newSubscriptionUnitWithPercentPrice.modelType - name = newSubscriptionUnitWithPercentPrice.name - unitWithPercentConfig = - newSubscriptionUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newSubscriptionUnitWithPercentPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithPercentPrice.conversionRate - currency = newSubscriptionUnitWithPercentPrice.currency - externalPriceId = newSubscriptionUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithPercentPrice.metadata - referenceId = newSubscriptionUnitWithPercentPrice.referenceId - additionalProperties = - newSubscriptionUnitWithPercentPrice.additionalProperties.toMutableMap() + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + currency = unitWithPercent.currency + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -36362,18 +33650,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -36708,7 +33997,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitWithPercentPrice]. + * Returns an immutable instance of [UnitWithPercent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -36716,18 +34005,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitWithPercentPrice = - NewSubscriptionUnitWithPercentPrice( + fun build(): UnitWithPercent = + UnitWithPercent( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithPercentConfig", unitWithPercentConfig), billableMetricId, @@ -36747,14 +34035,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitWithPercentPrice = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithPercentConfig().validate() billableMetricId() @@ -36789,7 +34081,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -36963,135 +34255,6 @@ private constructor( 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 UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * 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 { - UNIT_WITH_PERCENT, - /** - * 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) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - 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 UnitWithPercentConfig @JsonCreator private constructor( @@ -38043,7 +35206,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercent && 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 && currency == other.currency && 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 */ @@ -38053,14 +35216,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "UnitWithPercent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionPackageWithAllocationPrice + class PackageWithAllocation private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageWithAllocationConfig: JsonField, private val billableMetricId: JsonField, @@ -38087,7 +35250,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -38169,11 +35332,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -38315,16 +35482,6 @@ private constructor( */ @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]. * @@ -38472,13 +35629,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionPackageWithAllocationPrice]. + * [PackageWithAllocation]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` @@ -38486,12 +35642,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionPackageWithAllocationPrice]. */ + /** A builder for [PackageWithAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") private var name: JsonField? = null private var packageWithAllocationConfig: JsonField? = @@ -38513,35 +35669,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionPackageWithAllocationPrice: - NewSubscriptionPackageWithAllocationPrice - ) = apply { - cadence = newSubscriptionPackageWithAllocationPrice.cadence - itemId = newSubscriptionPackageWithAllocationPrice.itemId - modelType = newSubscriptionPackageWithAllocationPrice.modelType - name = newSubscriptionPackageWithAllocationPrice.name + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name packageWithAllocationConfig = - newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = - newSubscriptionPackageWithAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionPackageWithAllocationPrice.conversionRate - currency = newSubscriptionPackageWithAllocationPrice.currency - externalPriceId = newSubscriptionPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + currency = packageWithAllocation.currency + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionPackageWithAllocationPrice.metadata - referenceId = newSubscriptionPackageWithAllocationPrice.referenceId + packageWithAllocation.invoicingCycleConfiguration + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId additionalProperties = - newSubscriptionPackageWithAllocationPrice.additionalProperties - .toMutableMap() + packageWithAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -38568,18 +35716,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -38916,7 +36065,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionPackageWithAllocationPrice]. + * Returns an immutable instance of [PackageWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -38924,18 +36073,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionPackageWithAllocationPrice = - NewSubscriptionPackageWithAllocationPrice( + fun build(): PackageWithAllocation = + PackageWithAllocation( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "packageWithAllocationConfig", @@ -38958,14 +36106,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageWithAllocationConfig().validate() billableMetricId() @@ -39000,7 +36152,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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 (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -39174,135 +36328,6 @@ private constructor( 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 PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * 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 { - PACKAGE_WITH_ALLOCATION, - /** - * 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) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - 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 PackageWithAllocationConfig @JsonCreator private constructor( @@ -40256,7 +37281,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocation && 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 && currency == other.currency && 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 */ @@ -40266,14 +37291,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTierWithProrationPrice + class TieredWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -40300,7 +37325,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -40382,11 +37407,15 @@ private constructor( 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). + * 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). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -40528,16 +37557,6 @@ private constructor( */ @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]. * @@ -40685,13 +37704,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTierWithProrationPrice]. + * [TieredWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` @@ -40699,12 +37717,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTierWithProrationPrice]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null private var tieredWithProrationConfig: JsonField? = null @@ -40725,33 +37743,26 @@ private constructor( 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 - currency = newSubscriptionTierWithProrationPrice.currency - externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTierWithProrationPrice.invoiceGroupingKey + 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 + currency = tieredWithProration.currency + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionTierWithProrationPrice.metadata - referenceId = newSubscriptionTierWithProrationPrice.referenceId + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId additionalProperties = - newSubscriptionTierWithProrationPrice.additionalProperties - .toMutableMap() + tieredWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -40778,18 +37789,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -41125,7 +38137,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTierWithProrationPrice]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -41133,18 +38145,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, @@ -41164,14 +38175,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTierWithProrationPrice = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithProrationConfig().validate() billableMetricId() @@ -41206,7 +38221,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -41380,135 +38397,6 @@ private constructor( 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( @@ -42461,7 +39349,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 && currency == other.currency && 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 */ @@ -42471,14 +39359,14 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionUnitWithProrationPrice + class UnitWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -42505,7 +39393,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -42586,11 +39474,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -42732,16 +39624,6 @@ private constructor( */ @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]. * @@ -42889,13 +39771,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitWithProrationPrice]. + * [UnitWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` @@ -42903,12 +39784,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitWithProrationPrice]. */ + /** A builder for [UnitWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") private var name: JsonField? = null private var unitWithProrationConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -42928,33 +39809,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionUnitWithProrationPrice: NewSubscriptionUnitWithProrationPrice - ) = apply { - cadence = newSubscriptionUnitWithProrationPrice.cadence - itemId = newSubscriptionUnitWithProrationPrice.itemId - modelType = newSubscriptionUnitWithProrationPrice.modelType - name = newSubscriptionUnitWithProrationPrice.name - unitWithProrationConfig = - newSubscriptionUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newSubscriptionUnitWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithProrationPrice.conversionRate - currency = newSubscriptionUnitWithProrationPrice.currency - externalPriceId = newSubscriptionUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithProrationPrice.metadata - referenceId = newSubscriptionUnitWithProrationPrice.referenceId - additionalProperties = - newSubscriptionUnitWithProrationPrice.additionalProperties - .toMutableMap() + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + currency = unitWithProration.currency + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -42981,18 +39853,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -43327,7 +40200,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitWithProrationPrice]. + * Returns an immutable instance of [UnitWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -43335,18 +40208,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitWithProrationPrice = - NewSubscriptionUnitWithProrationPrice( + fun build(): UnitWithProration = + UnitWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithProrationConfig", unitWithProrationConfig), billableMetricId, @@ -43366,14 +40238,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitWithProrationPrice = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithProrationConfig().validate() billableMetricId() @@ -43408,7 +40284,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -43582,135 +40460,6 @@ private constructor( 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 UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_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 { - UNIT_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) { - UNIT_WITH_PRORATION -> Value.UNIT_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) { - UNIT_WITH_PRORATION -> Known.UNIT_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 UnitWithProrationConfig @JsonCreator private constructor( @@ -44663,7 +41412,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProration && 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 && currency == other.currency && 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 */ @@ -44673,15 +41422,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "UnitWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedAllocationPrice + class GroupedAllocation private constructor( private val cadence: JsonField, private val groupedAllocationConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -44710,7 +41459,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -44796,11 +41545,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -44945,16 +41698,6 @@ private constructor( */ @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]. * @@ -45091,27 +41834,26 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedAllocationPrice]. + * [GroupedAllocation]. * * The following fields are required: * ```java * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedAllocationPrice]. */ + /** A builder for [GroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedAllocationConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -45130,33 +41872,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedAllocationPrice: NewSubscriptionGroupedAllocationPrice - ) = apply { - cadence = newSubscriptionGroupedAllocationPrice.cadence - groupedAllocationConfig = - newSubscriptionGroupedAllocationPrice.groupedAllocationConfig - itemId = newSubscriptionGroupedAllocationPrice.itemId - modelType = newSubscriptionGroupedAllocationPrice.modelType - name = newSubscriptionGroupedAllocationPrice.name - billableMetricId = newSubscriptionGroupedAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedAllocationPrice.conversionRate - currency = newSubscriptionGroupedAllocationPrice.currency - externalPriceId = newSubscriptionGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedAllocationPrice.metadata - referenceId = newSubscriptionGroupedAllocationPrice.referenceId - additionalProperties = - newSubscriptionGroupedAllocationPrice.additionalProperties - .toMutableMap() + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + currency = groupedAllocation.currency + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -45197,18 +41930,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -45529,7 +42263,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionGroupedAllocationPrice]. + * Returns an immutable instance of [GroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -45538,18 +42272,17 @@ private constructor( * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedAllocationPrice = - NewSubscriptionGroupedAllocationPrice( + fun build(): GroupedAllocation = + GroupedAllocation( checkRequired("cadence", cadence), checkRequired("groupedAllocationConfig", groupedAllocationConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -45568,7 +42301,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedAllocationPrice = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -45576,7 +42309,11 @@ private constructor( cadence().validate() groupedAllocationConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -45611,7 +42348,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -45898,135 +42635,6 @@ private constructor( "GroupedAllocationConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * 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 { - GROUPED_ALLOCATION, - /** - * 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) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -46865,7 +43473,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocation && 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 && currency == other.currency && 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 */ @@ -46875,16 +43483,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedWithProratedMinimumPrice + class GroupedWithProratedMinimum private constructor( private val cadence: JsonField, private val groupedWithProratedMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -46914,7 +43522,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -47002,11 +43610,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -47151,16 +43763,6 @@ private constructor( */ @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]. * @@ -47297,21 +43899,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedWithProratedMinimumPrice]. + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedWithProratedMinimumPrice]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -47319,7 +43920,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -47338,41 +43940,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithProratedMinimumPrice: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithProratedMinimumPrice.cadence - groupedWithProratedMinimumConfig = - newSubscriptionGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newSubscriptionGroupedWithProratedMinimumPrice.itemId - modelType = newSubscriptionGroupedWithProratedMinimumPrice.modelType - name = newSubscriptionGroupedWithProratedMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithProratedMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithProratedMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + currency = groupedWithProratedMinimum.currency + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -47420,18 +44011,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -47752,8 +44344,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionGroupedWithProratedMinimumPrice]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -47762,21 +44353,20 @@ private constructor( * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedWithProratedMinimumPrice = - NewSubscriptionGroupedWithProratedMinimumPrice( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithProratedMinimumConfig", groupedWithProratedMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -47795,7 +44385,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -47803,7 +44393,11 @@ private constructor( cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -47838,7 +44432,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -48126,136 +44722,6 @@ private constructor( "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -49094,7 +45560,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimum && 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 && currency == other.currency && 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 */ @@ -49104,15 +45570,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkWithProrationPrice + class BulkWithProration private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -49141,7 +45607,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -49227,11 +45693,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -49376,16 +45846,6 @@ private constructor( */ @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]. * @@ -49522,27 +45982,26 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkWithProrationPrice]. + * [BulkWithProration]. * * The following fields are required: * ```java * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkWithProrationPrice]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -49561,33 +46020,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionBulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig - cadence = newSubscriptionBulkWithProrationPrice.cadence - itemId = newSubscriptionBulkWithProrationPrice.itemId - modelType = newSubscriptionBulkWithProrationPrice.modelType - name = newSubscriptionBulkWithProrationPrice.name - billableMetricId = newSubscriptionBulkWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkWithProrationPrice.conversionRate - currency = newSubscriptionBulkWithProrationPrice.currency - externalPriceId = newSubscriptionBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkWithProrationPrice.metadata - referenceId = newSubscriptionBulkWithProrationPrice.referenceId - additionalProperties = - newSubscriptionBulkWithProrationPrice.additionalProperties - .toMutableMap() + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + currency = bulkWithProration.currency + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = @@ -49628,18 +46078,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -49960,7 +46411,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkWithProrationPrice]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -49969,18 +46420,17 @@ private constructor( * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkWithProrationPrice = - NewSubscriptionBulkWithProrationPrice( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -49999,7 +46449,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkWithProrationPrice = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -50007,7 +46457,11 @@ private constructor( bulkWithProrationConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -50042,7 +46496,9 @@ private constructor( (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -50329,135 +46785,6 @@ private constructor( 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 BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_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 { - BULK_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) { - BULK_WITH_PRORATION -> Value.BULK_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) { - BULK_WITH_PRORATION -> Known.BULK_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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -51296,7 +47623,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkWithProration && 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 && currency == other.currency && 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 */ @@ -51306,14 +47633,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionScalableMatrixWithUnitPricingPrice + class ScalableMatrixWithUnitPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithUnitPricingConfig: JsonField, @@ -51341,7 +47668,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -51424,11 +47751,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -51572,16 +47903,6 @@ private constructor( */ @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]. * @@ -51730,13 +48051,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionScalableMatrixWithUnitPricingPrice]. + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` @@ -51744,12 +48064,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var scalableMatrixWithUnitPricingConfig: JsonField? = @@ -51772,40 +48093,29 @@ private constructor( @JvmSynthetic internal fun from( - newSubscriptionScalableMatrixWithUnitPricingPrice: - NewSubscriptionScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = apply { - cadence = newSubscriptionScalableMatrixWithUnitPricingPrice.cadence - itemId = newSubscriptionScalableMatrixWithUnitPricingPrice.itemId - modelType = newSubscriptionScalableMatrixWithUnitPricingPrice.modelType - name = newSubscriptionScalableMatrixWithUnitPricingPrice.name + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name scalableMatrixWithUnitPricingConfig = - newSubscriptionScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = - newSubscriptionScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = - newSubscriptionScalableMatrixWithUnitPricingPrice.billedInAdvance + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance billingCycleConfiguration = - newSubscriptionScalableMatrixWithUnitPricingPrice - .billingCycleConfiguration - conversionRate = - newSubscriptionScalableMatrixWithUnitPricingPrice.conversionRate - currency = newSubscriptionScalableMatrixWithUnitPricingPrice.currency - externalPriceId = - newSubscriptionScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionScalableMatrixWithUnitPricingPrice.invoiceGroupingKey + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + currency = scalableMatrixWithUnitPricing.currency + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionScalableMatrixWithUnitPricingPrice - .invoicingCycleConfiguration - metadata = newSubscriptionScalableMatrixWithUnitPricingPrice.metadata - referenceId = newSubscriptionScalableMatrixWithUnitPricingPrice.referenceId + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId additionalProperties = - newSubscriptionScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -51832,18 +48142,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -52188,8 +48499,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionScalableMatrixWithUnitPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -52197,18 +48507,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionScalableMatrixWithUnitPricingPrice = - NewSubscriptionScalableMatrixWithUnitPricingPrice( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithUnitPricingConfig", @@ -52231,14 +48540,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionScalableMatrixWithUnitPricingPrice = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -52273,7 +48586,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -52448,139 +48763,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_UNIT_PRICING = - of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - 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 ScalableMatrixWithUnitPricingConfig @JsonCreator private constructor( @@ -53535,7 +49717,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithUnitPricing && 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 && currency == other.currency && 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 */ @@ -53545,14 +49727,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionScalableMatrixWithTieredPricingPrice + class ScalableMatrixWithTieredPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithTieredPricingConfig: JsonField, @@ -53580,7 +49762,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -53663,11 +49845,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -53811,16 +49997,6 @@ private constructor( */ @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]. * @@ -53969,13 +50145,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionScalableMatrixWithTieredPricingPrice]. + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` @@ -53983,12 +50158,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionScalableMatrixWithTieredPricingPrice]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var scalableMatrixWithTieredPricingConfig: JsonField? = @@ -54011,41 +50187,29 @@ private constructor( @JvmSynthetic internal fun from( - newSubscriptionScalableMatrixWithTieredPricingPrice: - NewSubscriptionScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = apply { - cadence = newSubscriptionScalableMatrixWithTieredPricingPrice.cadence - itemId = newSubscriptionScalableMatrixWithTieredPricingPrice.itemId - modelType = newSubscriptionScalableMatrixWithTieredPricingPrice.modelType - name = newSubscriptionScalableMatrixWithTieredPricingPrice.name + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name scalableMatrixWithTieredPricingConfig = - newSubscriptionScalableMatrixWithTieredPricingPrice - .scalableMatrixWithTieredPricingConfig - billableMetricId = - newSubscriptionScalableMatrixWithTieredPricingPrice.billableMetricId - billedInAdvance = - newSubscriptionScalableMatrixWithTieredPricingPrice.billedInAdvance + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance billingCycleConfiguration = - newSubscriptionScalableMatrixWithTieredPricingPrice - .billingCycleConfiguration - conversionRate = - newSubscriptionScalableMatrixWithTieredPricingPrice.conversionRate - currency = newSubscriptionScalableMatrixWithTieredPricingPrice.currency - externalPriceId = - newSubscriptionScalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionScalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionScalableMatrixWithTieredPricingPrice.invoiceGroupingKey + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + currency = scalableMatrixWithTieredPricing.currency + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionScalableMatrixWithTieredPricingPrice - .invoicingCycleConfiguration - metadata = newSubscriptionScalableMatrixWithTieredPricingPrice.metadata - referenceId = - newSubscriptionScalableMatrixWithTieredPricingPrice.referenceId + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId additionalProperties = - newSubscriptionScalableMatrixWithTieredPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -54072,18 +50236,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -54428,8 +50593,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionScalableMatrixWithTieredPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -54437,18 +50601,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionScalableMatrixWithTieredPricingPrice = - NewSubscriptionScalableMatrixWithTieredPricingPrice( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithTieredPricingConfig", @@ -54471,14 +50634,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionScalableMatrixWithTieredPricingPrice = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -54513,7 +50680,10 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -54688,139 +50858,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - 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 ScalableMatrixWithTieredPricingConfig @JsonCreator private constructor( @@ -55778,7 +51815,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithTieredPricing && 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 && currency == other.currency && 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 */ @@ -55788,15 +51825,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionCumulativeGroupedBulkPrice + class CumulativeGroupedBulk private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -55826,7 +51863,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -55912,11 +51949,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -56061,16 +52102,6 @@ private constructor( */ @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]. * @@ -56207,21 +52238,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionCumulativeGroupedBulkPrice]. + * [CumulativeGroupedBulk]. * * The following fields are required: * ```java * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionCumulativeGroupedBulkPrice]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -56229,7 +52259,7 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -56248,35 +52278,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionCumulativeGroupedBulkPrice: - NewSubscriptionCumulativeGroupedBulkPrice - ) = apply { - cadence = newSubscriptionCumulativeGroupedBulkPrice.cadence + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence cumulativeGroupedBulkConfig = - newSubscriptionCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - itemId = newSubscriptionCumulativeGroupedBulkPrice.itemId - modelType = newSubscriptionCumulativeGroupedBulkPrice.modelType - name = newSubscriptionCumulativeGroupedBulkPrice.name - billableMetricId = - newSubscriptionCumulativeGroupedBulkPrice.billableMetricId - billedInAdvance = newSubscriptionCumulativeGroupedBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionCumulativeGroupedBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionCumulativeGroupedBulkPrice.conversionRate - currency = newSubscriptionCumulativeGroupedBulkPrice.currency - externalPriceId = newSubscriptionCumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionCumulativeGroupedBulkPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionCumulativeGroupedBulkPrice.invoiceGroupingKey + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + currency = cumulativeGroupedBulk.currency + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionCumulativeGroupedBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionCumulativeGroupedBulkPrice.metadata - referenceId = newSubscriptionCumulativeGroupedBulkPrice.referenceId + cumulativeGroupedBulk.invoicingCycleConfiguration + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId additionalProperties = - newSubscriptionCumulativeGroupedBulkPrice.additionalProperties - .toMutableMap() + cumulativeGroupedBulk.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -56319,18 +52341,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -56651,7 +52674,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionCumulativeGroupedBulkPrice]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -56660,21 +52683,20 @@ private constructor( * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionCumulativeGroupedBulkPrice = - NewSubscriptionCumulativeGroupedBulkPrice( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("cadence", cadence), checkRequired( "cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -56693,7 +52715,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionCumulativeGroupedBulkPrice = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -56701,7 +52723,11 @@ private constructor( cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -56736,7 +52762,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -57024,135 +53052,6 @@ private constructor( "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * 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 { - CUMULATIVE_GROUPED_BULK, - /** - * 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) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -57991,7 +53890,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CumulativeGroupedBulk && 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 && currency == other.currency && 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 */ @@ -58001,15 +53900,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMaxGroupTieredPackagePrice + class MaxGroupTieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, private val maxGroupTieredPackageConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -58039,7 +53938,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -58125,11 +54024,15 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_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). + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -58274,16 +54177,6 @@ private constructor( fun _maxGroupTieredPackageConfig(): JsonField = maxGroupTieredPackageConfig - /** - * 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]. * @@ -58420,21 +54313,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMaxGroupTieredPackagePrice]. + * [MaxGroupTieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMaxGroupTieredPackagePrice]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -58442,7 +54334,7 @@ private constructor( private var maxGroupTieredPackageConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -58461,35 +54353,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionMaxGroupTieredPackagePrice: - NewSubscriptionMaxGroupTieredPackagePrice - ) = apply { - cadence = newSubscriptionMaxGroupTieredPackagePrice.cadence - itemId = newSubscriptionMaxGroupTieredPackagePrice.itemId + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId maxGroupTieredPackageConfig = - newSubscriptionMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newSubscriptionMaxGroupTieredPackagePrice.modelType - name = newSubscriptionMaxGroupTieredPackagePrice.name - billableMetricId = - newSubscriptionMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionMaxGroupTieredPackagePrice.conversionRate - currency = newSubscriptionMaxGroupTieredPackagePrice.currency - externalPriceId = newSubscriptionMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionMaxGroupTieredPackagePrice.invoiceGroupingKey + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + currency = maxGroupTieredPackage.currency + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionMaxGroupTieredPackagePrice.metadata - referenceId = newSubscriptionMaxGroupTieredPackagePrice.referenceId + maxGroupTieredPackage.invoicingCycleConfiguration + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId additionalProperties = - newSubscriptionMaxGroupTieredPackagePrice.additionalProperties - .toMutableMap() + maxGroupTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -58532,18 +54416,19 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -58864,7 +54749,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMaxGroupTieredPackagePrice]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -58873,21 +54758,20 @@ private constructor( * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMaxGroupTieredPackagePrice = - NewSubscriptionMaxGroupTieredPackagePrice( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired( "maxGroupTieredPackageConfig", maxGroupTieredPackageConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -58906,7 +54790,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMaxGroupTieredPackagePrice = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -58914,7 +54798,11 @@ private constructor( cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -58949,7 +54837,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -59237,135 +55127,6 @@ private constructor( "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * 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 { - MAX_GROUP_TIERED_PACKAGE, - /** - * 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) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -60204,7 +55965,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MaxGroupTieredPackage && 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 && currency == other.currency && 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 */ @@ -60214,16 +55975,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedWithMeteredMinimumPrice + class GroupedWithMeteredMinimum private constructor( private val cadence: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -60253,7 +56014,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -60341,11 +56102,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -60490,16 +56255,6 @@ private constructor( */ @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]. * @@ -60636,21 +56391,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedWithMeteredMinimumPrice]. + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedWithMeteredMinimumPrice]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -60658,7 +56412,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -60677,41 +56432,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithMeteredMinimumPrice: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithMeteredMinimumPrice.cadence - groupedWithMeteredMinimumConfig = - newSubscriptionGroupedWithMeteredMinimumPrice - .groupedWithMeteredMinimumConfig - itemId = newSubscriptionGroupedWithMeteredMinimumPrice.itemId - modelType = newSubscriptionGroupedWithMeteredMinimumPrice.modelType - name = newSubscriptionGroupedWithMeteredMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithMeteredMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithMeteredMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithMeteredMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithMeteredMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithMeteredMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithMeteredMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithMeteredMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + currency = groupedWithMeteredMinimum.currency + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -60758,18 +56502,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -61090,8 +56835,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionGroupedWithMeteredMinimumPrice]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -61100,21 +56844,20 @@ private constructor( * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedWithMeteredMinimumPrice = - NewSubscriptionGroupedWithMeteredMinimumPrice( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithMeteredMinimumConfig", groupedWithMeteredMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -61133,7 +56876,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedWithMeteredMinimumPrice = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -61141,7 +56884,11 @@ private constructor( cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -61176,7 +56923,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -61464,136 +57213,6 @@ private constructor( "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -62432,7 +58051,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimum && 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 && currency == other.currency && 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 */ @@ -62442,15 +58061,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMatrixWithDisplayNamePrice + class MatrixWithDisplayName private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixWithDisplayNameConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -62480,7 +58099,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -62566,11 +58185,15 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -62715,16 +58338,6 @@ private constructor( fun _matrixWithDisplayNameConfig(): JsonField = matrixWithDisplayNameConfig - /** - * 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]. * @@ -62861,21 +58474,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMatrixWithDisplayNamePrice]. + * [MatrixWithDisplayName]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMatrixWithDisplayNamePrice]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -62883,7 +58495,7 @@ private constructor( private var matrixWithDisplayNameConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -62902,35 +58514,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionMatrixWithDisplayNamePrice: - NewSubscriptionMatrixWithDisplayNamePrice - ) = apply { - cadence = newSubscriptionMatrixWithDisplayNamePrice.cadence - itemId = newSubscriptionMatrixWithDisplayNamePrice.itemId + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId matrixWithDisplayNameConfig = - newSubscriptionMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newSubscriptionMatrixWithDisplayNamePrice.modelType - name = newSubscriptionMatrixWithDisplayNamePrice.name - billableMetricId = - newSubscriptionMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newSubscriptionMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixWithDisplayNamePrice.conversionRate - currency = newSubscriptionMatrixWithDisplayNamePrice.currency - externalPriceId = newSubscriptionMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionMatrixWithDisplayNamePrice.invoiceGroupingKey + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + currency = matrixWithDisplayName.currency + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixWithDisplayNamePrice.metadata - referenceId = newSubscriptionMatrixWithDisplayNamePrice.referenceId + matrixWithDisplayName.invoicingCycleConfiguration + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId additionalProperties = - newSubscriptionMatrixWithDisplayNamePrice.additionalProperties - .toMutableMap() + matrixWithDisplayName.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -62973,18 +58577,19 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -63305,7 +58910,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMatrixWithDisplayNamePrice]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -63314,21 +58919,20 @@ private constructor( * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMatrixWithDisplayNamePrice = - NewSubscriptionMatrixWithDisplayNamePrice( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired( "matrixWithDisplayNameConfig", matrixWithDisplayNameConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -63347,7 +58951,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMatrixWithDisplayNamePrice = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -63355,7 +58959,11 @@ private constructor( cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -63390,7 +58998,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -63678,135 +59288,6 @@ private constructor( "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * 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 { - MATRIX_WITH_DISPLAY_NAME, - /** - * 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) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -64645,7 +60126,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayName && 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 && currency == other.currency && 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 */ @@ -64655,15 +60136,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedTieredPackagePrice + class GroupedTieredPackage private constructor( private val cadence: JsonField, private val groupedTieredPackageConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -64693,7 +60174,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -64779,11 +60260,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -64928,16 +60413,6 @@ private constructor( */ @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]. * @@ -65074,28 +60549,27 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedTieredPackagePrice]. + * [GroupedTieredPackage]. * * The following fields are required: * ```java * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedTieredPackagePrice]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedTieredPackageConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -65114,34 +60588,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedTieredPackagePrice: - NewSubscriptionGroupedTieredPackagePrice - ) = apply { - cadence = newSubscriptionGroupedTieredPackagePrice.cadence - groupedTieredPackageConfig = - newSubscriptionGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newSubscriptionGroupedTieredPackagePrice.itemId - modelType = newSubscriptionGroupedTieredPackagePrice.modelType - name = newSubscriptionGroupedTieredPackagePrice.name - billableMetricId = newSubscriptionGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionGroupedTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedTieredPackagePrice.conversionRate - currency = newSubscriptionGroupedTieredPackagePrice.currency - externalPriceId = newSubscriptionGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedTieredPackagePrice.invoiceGroupingKey + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + currency = groupedTieredPackage.currency + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedTieredPackagePrice.metadata - referenceId = newSubscriptionGroupedTieredPackagePrice.referenceId + groupedTieredPackage.invoicingCycleConfiguration + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId additionalProperties = - newSubscriptionGroupedTieredPackagePrice.additionalProperties - .toMutableMap() + groupedTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -65184,18 +60650,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -65516,7 +60983,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionGroupedTieredPackagePrice]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -65525,18 +60992,17 @@ private constructor( * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedTieredPackagePrice = - NewSubscriptionGroupedTieredPackagePrice( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("cadence", cadence), checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -65555,7 +61021,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedTieredPackagePrice = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -65563,7 +61029,11 @@ private constructor( cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -65598,7 +61068,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -65885,135 +61357,6 @@ private constructor( "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * 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 { - GROUPED_TIERED_PACKAGE, - /** - * 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) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -66852,7 +62195,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPackage && 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 && currency == other.currency && 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 */ @@ -66862,7 +62205,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -67859,32 +63202,26 @@ private constructor( /** * Alias for calling [adjustment] with - * `Adjustment.ofNewPercentageDiscount(newPercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewUsageDiscount(newUsageDiscount)`. - */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewAmountDiscount(newAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMinimum(newMinimum)`. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMaximum(newMaximum)`. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The id of the adjustment on the plan to replace in the subscription. */ fun replacesAdjustmentId(replacesAdjustmentId: String) = @@ -67977,60 +63314,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isNewMinimum(): Boolean = newMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isNewMaximum(): Boolean = newMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) + 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) } @@ -68042,27 +63375,27 @@ private constructor( } accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - newPercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -68087,19 +63420,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) = newPercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - newUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - newAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -68110,19 +63443,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ + 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 hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" + 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") } @@ -68130,22 +63463,20 @@ private constructor( companion object { @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -68154,15 +63485,15 @@ private constructor( */ interface Visitor { - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitNewMinimum(newMinimum: NewMinimum): T + fun visitMinimum(minimum: Minimum): T - fun visitNewMaximum(newMaximum: NewMaximum): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -68188,28 +63519,28 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(newPercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newUsageDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newAmountDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMinimum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMaximum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) } ?: Adjustment(_json = json) } } @@ -68226,23 +63557,21 @@ private constructor( provider: SerializerProvider, ) { when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) + 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") } } } - class NewPercentageDiscount + class PercentageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val percentageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -68253,7 +63582,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -68272,11 +63601,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -68306,16 +63641,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -68362,11 +63687,10 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPercentageDiscount]. + * [PercentageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` @@ -68374,37 +63698,39 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPercentageDiscount]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var percentageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.percentageDiscount = percentageDiscount.percentageDiscount + isInvoiceLevel = percentageDiscount.isInvoiceLevel additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -68490,22 +63816,21 @@ private constructor( } /** - * Returns an immutable instance of [NewPercentageDiscount]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): PercentageDiscount = + PercentageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -68517,12 +63842,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPercentageDiscount = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() percentageDiscount() isInvoiceLevel() @@ -68545,147 +63876,19 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -68695,12 +63898,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "PercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewUsageDiscount + class UsageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val usageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -68711,7 +63914,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -68730,11 +63933,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -68763,16 +63972,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -68818,11 +64017,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewUsageDiscount]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` @@ -68830,36 +64028,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewUsageDiscount]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var usageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.usageDiscount = usageDiscount.usageDiscount + isInvoiceLevel = usageDiscount.isInvoiceLevel + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -68945,22 +64145,21 @@ private constructor( } /** - * Returns an immutable instance of [NewUsageDiscount]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): UsageDiscount = + UsageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -68972,12 +64171,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewUsageDiscount = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() usageDiscount() isInvoiceLevel() @@ -69000,147 +64205,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("usage_discount")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -69150,12 +64225,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "UsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewAmountDiscount + class AmountDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -69166,7 +64241,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -69185,11 +64260,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -69218,16 +64299,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -69273,12 +64344,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewAmountDiscount]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` @@ -69286,36 +64355,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewAmountDiscount]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -69401,22 +64472,21 @@ private constructor( } /** - * Returns an immutable instance of [NewAmountDiscount]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): AmountDiscount = + AmountDiscount( + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -69428,12 +64498,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewAmountDiscount = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -69456,147 +64532,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("amount_discount")) 1 else 0 } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -69606,12 +64552,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "AmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMinimum + class Minimum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val itemId: JsonField, private val minimumAmount: JsonField, @@ -69623,7 +64569,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -69646,11 +64592,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -69688,16 +64640,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -69751,11 +64693,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMinimum]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -69764,10 +64705,10 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMinimum]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var itemId: JsonField? = null private var minimumAmount: JsonField? = null @@ -69775,26 +64716,28 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() + internal fun from(minimum: Minimum) = apply { + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + isInvoiceLevel = minimum.isInvoiceLevel + additionalProperties = minimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -69892,13 +64835,12 @@ private constructor( } /** - * Returns an immutable instance of [NewMinimum]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -69906,9 +64848,9 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Minimum = + Minimum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -69921,12 +64863,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMinimum = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() itemId() minimumAmount() @@ -69950,148 +64898,18 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -70101,12 +64919,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Minimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMaximum + class Maximum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val maximumAmount: JsonField, private val isInvoiceLevel: JsonField, @@ -70117,7 +64935,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -70136,11 +64954,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -70169,16 +64993,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -70224,11 +65038,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMaximum]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` @@ -70236,35 +65049,37 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMaximum]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var maximumAmount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() + internal fun from(maximum: Maximum) = apply { + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + maximumAmount = maximum.maximumAmount + isInvoiceLevel = maximum.isInvoiceLevel + additionalProperties = maximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -70350,22 +65165,21 @@ private constructor( } /** - * Returns an immutable instance of [NewMaximum]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Maximum = + Maximum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -70377,12 +65191,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMaximum = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() maximumAmount() isInvoiceLevel() @@ -70405,147 +65225,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -70555,7 +65245,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Maximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } } @@ -71032,244 +65722,127 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } - /** - * Alias for calling [price] with `Price.ofNewSubscriptionUnit(newSubscriptionUnit)`. - */ - fun price(newSubscriptionUnit: Price.NewSubscriptionUnitPrice) = - price(Price.ofNewSubscriptionUnit(newSubscriptionUnit)) + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionPackage(newSubscriptionPackage)`. - */ - fun price(newSubscriptionPackage: Price.NewSubscriptionPackagePrice) = - price(Price.ofNewSubscriptionPackage(newSubscriptionPackage)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)`. - */ - fun price(newSubscriptionMatrix: Price.NewSubscriptionMatrixPrice) = - price(Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)) + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTiered(newSubscriptionTiered)`. - */ - fun price(newSubscriptionTiered: Price.NewSubscriptionTieredPrice) = - price(Price.ofNewSubscriptionTiered(newSubscriptionTiered)) + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)`. - */ - fun price(newSubscriptionTieredBps: Price.NewSubscriptionTieredBpsPrice) = - price(Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)) + /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - /** Alias for calling [price] with `Price.ofNewSubscriptionBps(newSubscriptionBps)`. */ - fun price(newSubscriptionBps: Price.NewSubscriptionBpsPrice) = - price(Price.ofNewSubscriptionBps(newSubscriptionBps)) + /** Alias for calling [price] with `Price.ofBps(bps)`. */ + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)`. - */ - fun price(newSubscriptionBulkBps: Price.NewSubscriptionBulkBpsPrice) = - price(Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)) + /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** - * Alias for calling [price] with `Price.ofNewSubscriptionBulk(newSubscriptionBulk)`. - */ - fun price(newSubscriptionBulk: Price.NewSubscriptionBulkPrice) = - price(Price.ofNewSubscriptionBulk(newSubscriptionBulk)) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount)`. + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price( - newSubscriptionThresholdTotalAmount: Price.NewSubscriptionThresholdTotalAmountPrice - ) = - price( - Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount) - ) + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)`. - */ - fun price(newSubscriptionTieredPackage: Price.NewSubscriptionTieredPackagePrice) = - price(Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)) + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: Price.TieredPackage) = + price(Price.ofTieredPackage(tieredPackage)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)`. - */ - fun price( - newSubscriptionTieredWithMinimum: Price.NewSubscriptionTieredWithMinimumPrice - ) = price(Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: Price.TieredWithMinimum) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)`. - */ - fun price(newSubscriptionUnitWithPercent: Price.NewSubscriptionUnitWithPercentPrice) = - price(Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: Price.UnitWithPercent) = + price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionPackageWithAllocation(newSubscriptionPackageWithAllocation)`. + * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price( - newSubscriptionPackageWithAllocation: - Price.NewSubscriptionPackageWithAllocationPrice - ) = - price( - Price.ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - ) + fun price(packageWithAllocation: Price.PackageWithAllocation) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)`. + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price( - newSubscriptionTierWithProration: Price.NewSubscriptionTierWithProrationPrice - ) = price(Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)) + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)`. - */ - fun price( - newSubscriptionUnitWithProration: Price.NewSubscriptionUnitWithProrationPrice - ) = price(Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: Price.UnitWithProration) = + price(Price.ofUnitWithProration(unitWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)`. - */ - fun price( - newSubscriptionGroupedAllocation: Price.NewSubscriptionGroupedAllocationPrice - ) = price(Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)) + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: Price.GroupedAllocation) = + price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedWithProratedMinimum(newSubscriptionGroupedWithProratedMinimum)`. + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price( - newSubscriptionGroupedWithProratedMinimum: - Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - ) + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)`. - */ - fun price( - newSubscriptionBulkWithProration: Price.NewSubscriptionBulkWithProrationPrice - ) = price(Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionScalableMatrixWithUnitPricing(newSubscriptionScalableMatrixWithUnitPricing)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price( - newSubscriptionScalableMatrixWithUnitPricing: - Price.NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = - price( - Price.ofNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing - ) - ) + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionScalableMatrixWithTieredPricing(newSubscriptionScalableMatrixWithTieredPricing)`. + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - newSubscriptionScalableMatrixWithTieredPricing: - Price.NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = - price( - Price.ofNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing - ) - ) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionCumulativeGroupedBulk(newSubscriptionCumulativeGroupedBulk)`. + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price( - newSubscriptionCumulativeGroupedBulk: - Price.NewSubscriptionCumulativeGroupedBulkPrice - ) = - price( - Price.ofNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk - ) - ) + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionMaxGroupTieredPackage(newSubscriptionMaxGroupTieredPackage)`. + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price( - newSubscriptionMaxGroupTieredPackage: - Price.NewSubscriptionMaxGroupTieredPackagePrice - ) = - price( - Price.ofNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage - ) - ) + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedWithMeteredMinimum(newSubscriptionGroupedWithMeteredMinimum)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price( - newSubscriptionGroupedWithMeteredMinimum: - Price.NewSubscriptionGroupedWithMeteredMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum - ) - ) + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionMatrixWithDisplayName(newSubscriptionMatrixWithDisplayName)`. + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price( - newSubscriptionMatrixWithDisplayName: - Price.NewSubscriptionMatrixWithDisplayNamePrice - ) = - price( - Price.ofNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName - ) - ) + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedTieredPackage(newSubscriptionGroupedTieredPackage)`. + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price( - newSubscriptionGroupedTieredPackage: Price.NewSubscriptionGroupedTieredPackagePrice - ) = - price( - Price.ofNewSubscriptionGroupedTieredPackage(newSubscriptionGroupedTieredPackage) - ) + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -72320,401 +66893,257 @@ private constructor( @JsonSerialize(using = Price.Serializer::class) class Price private constructor( - private val newSubscriptionUnit: NewSubscriptionUnitPrice? = null, - private val newSubscriptionPackage: NewSubscriptionPackagePrice? = null, - private val newSubscriptionMatrix: NewSubscriptionMatrixPrice? = null, - private val newSubscriptionTiered: NewSubscriptionTieredPrice? = null, - private val newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice? = null, - private val newSubscriptionBps: NewSubscriptionBpsPrice? = null, - private val newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice? = null, - private val newSubscriptionBulk: NewSubscriptionBulkPrice? = null, - private val newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice? = - null, - private val newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = - null, - private val newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice? = - null, - private val newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice? = - null, - private val newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice? = - null, - private val newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice? = - null, - private val newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice? = - null, - private val newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice? = - null, - private val newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice? = - null, - private val newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice? = - null, - private val newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice? = - null, + 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 thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val bulkWithProration: BulkWithProration? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, private val _json: JsonValue? = null, ) { - fun newSubscriptionUnit(): Optional = - Optional.ofNullable(newSubscriptionUnit) + fun unit(): Optional = Optional.ofNullable(unit) - fun newSubscriptionPackage(): Optional = - Optional.ofNullable(newSubscriptionPackage) + fun package_(): Optional = Optional.ofNullable(package_) - fun newSubscriptionMatrix(): Optional = - Optional.ofNullable(newSubscriptionMatrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun newSubscriptionTiered(): Optional = - Optional.ofNullable(newSubscriptionTiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun newSubscriptionTieredBps(): Optional = - Optional.ofNullable(newSubscriptionTieredBps) + fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - fun newSubscriptionBps(): Optional = - Optional.ofNullable(newSubscriptionBps) + fun bps(): Optional = Optional.ofNullable(bps) - fun newSubscriptionBulkBps(): Optional = - Optional.ofNullable(newSubscriptionBulkBps) + fun bulkBps(): Optional = Optional.ofNullable(bulkBps) - fun newSubscriptionBulk(): Optional = - Optional.ofNullable(newSubscriptionBulk) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun newSubscriptionThresholdTotalAmount(): - Optional = - Optional.ofNullable(newSubscriptionThresholdTotalAmount) + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) - fun newSubscriptionTieredPackage(): Optional = - Optional.ofNullable(newSubscriptionTieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun newSubscriptionTieredWithMinimum(): - Optional = - Optional.ofNullable(newSubscriptionTieredWithMinimum) + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) - fun newSubscriptionUnitWithPercent(): Optional = - Optional.ofNullable(newSubscriptionUnitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun newSubscriptionPackageWithAllocation(): - Optional = - Optional.ofNullable(newSubscriptionPackageWithAllocation) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) - fun newSubscriptionTierWithProration(): - Optional = - Optional.ofNullable(newSubscriptionTierWithProration) + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) - fun newSubscriptionUnitWithProration(): - Optional = - Optional.ofNullable(newSubscriptionUnitWithProration) + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) - fun newSubscriptionGroupedAllocation(): - Optional = - Optional.ofNullable(newSubscriptionGroupedAllocation) + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) - fun newSubscriptionGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithProratedMinimum) + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) - fun newSubscriptionBulkWithProration(): - Optional = - Optional.ofNullable(newSubscriptionBulkWithProration) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) - fun newSubscriptionScalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(newSubscriptionScalableMatrixWithUnitPricing) + fun scalableMatrixWithUnitPricing(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) - fun newSubscriptionScalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(newSubscriptionScalableMatrixWithTieredPricing) + fun scalableMatrixWithTieredPricing(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) - fun newSubscriptionCumulativeGroupedBulk(): - Optional = - Optional.ofNullable(newSubscriptionCumulativeGroupedBulk) + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) - fun newSubscriptionMaxGroupTieredPackage(): - Optional = - Optional.ofNullable(newSubscriptionMaxGroupTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) - fun newSubscriptionGroupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithMeteredMinimum) + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) - fun newSubscriptionMatrixWithDisplayName(): - Optional = - Optional.ofNullable(newSubscriptionMatrixWithDisplayName) + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) - fun newSubscriptionGroupedTieredPackage(): - Optional = - Optional.ofNullable(newSubscriptionGroupedTieredPackage) + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) - fun isNewSubscriptionUnit(): Boolean = newSubscriptionUnit != null + fun isUnit(): Boolean = unit != null - fun isNewSubscriptionPackage(): Boolean = newSubscriptionPackage != null + fun isPackage(): Boolean = package_ != null - fun isNewSubscriptionMatrix(): Boolean = newSubscriptionMatrix != null + fun isMatrix(): Boolean = matrix != null - fun isNewSubscriptionTiered(): Boolean = newSubscriptionTiered != null + fun isTiered(): Boolean = tiered != null - fun isNewSubscriptionTieredBps(): Boolean = newSubscriptionTieredBps != null + fun isTieredBps(): Boolean = tieredBps != null - fun isNewSubscriptionBps(): Boolean = newSubscriptionBps != null + fun isBps(): Boolean = bps != null - fun isNewSubscriptionBulkBps(): Boolean = newSubscriptionBulkBps != null + fun isBulkBps(): Boolean = bulkBps != null - fun isNewSubscriptionBulk(): Boolean = newSubscriptionBulk != null + fun isBulk(): Boolean = bulk != null - fun isNewSubscriptionThresholdTotalAmount(): Boolean = - newSubscriptionThresholdTotalAmount != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isNewSubscriptionTieredPackage(): Boolean = newSubscriptionTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null - fun isNewSubscriptionTieredWithMinimum(): Boolean = - newSubscriptionTieredWithMinimum != null + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isNewSubscriptionUnitWithPercent(): Boolean = newSubscriptionUnitWithPercent != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun isNewSubscriptionPackageWithAllocation(): Boolean = - newSubscriptionPackageWithAllocation != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun isNewSubscriptionTierWithProration(): Boolean = - newSubscriptionTierWithProration != null + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun isNewSubscriptionUnitWithProration(): Boolean = - newSubscriptionUnitWithProration != null + fun isUnitWithProration(): Boolean = unitWithProration != null - fun isNewSubscriptionGroupedAllocation(): Boolean = - newSubscriptionGroupedAllocation != null + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isNewSubscriptionGroupedWithProratedMinimum(): Boolean = - newSubscriptionGroupedWithProratedMinimum != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun isNewSubscriptionBulkWithProration(): Boolean = - newSubscriptionBulkWithProration != null + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isNewSubscriptionScalableMatrixWithUnitPricing(): Boolean = - newSubscriptionScalableMatrixWithUnitPricing != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isNewSubscriptionScalableMatrixWithTieredPricing(): Boolean = - newSubscriptionScalableMatrixWithTieredPricing != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isNewSubscriptionCumulativeGroupedBulk(): Boolean = - newSubscriptionCumulativeGroupedBulk != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isNewSubscriptionMaxGroupTieredPackage(): Boolean = - newSubscriptionMaxGroupTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isNewSubscriptionGroupedWithMeteredMinimum(): Boolean = - newSubscriptionGroupedWithMeteredMinimum != null + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isNewSubscriptionMatrixWithDisplayName(): Boolean = - newSubscriptionMatrixWithDisplayName != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isNewSubscriptionGroupedTieredPackage(): Boolean = - newSubscriptionGroupedTieredPackage != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun asNewSubscriptionUnit(): NewSubscriptionUnitPrice = - newSubscriptionUnit.getOrThrow("newSubscriptionUnit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asNewSubscriptionPackage(): NewSubscriptionPackagePrice = - newSubscriptionPackage.getOrThrow("newSubscriptionPackage") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asNewSubscriptionMatrix(): NewSubscriptionMatrixPrice = - newSubscriptionMatrix.getOrThrow("newSubscriptionMatrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asNewSubscriptionTiered(): NewSubscriptionTieredPrice = - newSubscriptionTiered.getOrThrow("newSubscriptionTiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asNewSubscriptionTieredBps(): NewSubscriptionTieredBpsPrice = - newSubscriptionTieredBps.getOrThrow("newSubscriptionTieredBps") + fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - fun asNewSubscriptionBps(): NewSubscriptionBpsPrice = - newSubscriptionBps.getOrThrow("newSubscriptionBps") + fun asBps(): Bps = bps.getOrThrow("bps") - fun asNewSubscriptionBulkBps(): NewSubscriptionBulkBpsPrice = - newSubscriptionBulkBps.getOrThrow("newSubscriptionBulkBps") + fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") - fun asNewSubscriptionBulk(): NewSubscriptionBulkPrice = - newSubscriptionBulk.getOrThrow("newSubscriptionBulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") - fun asNewSubscriptionThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - newSubscriptionThresholdTotalAmount.getOrThrow( - "newSubscriptionThresholdTotalAmount" - ) + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asNewSubscriptionTieredPackage(): NewSubscriptionTieredPackagePrice = - newSubscriptionTieredPackage.getOrThrow("newSubscriptionTieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asNewSubscriptionTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - newSubscriptionTieredWithMinimum.getOrThrow("newSubscriptionTieredWithMinimum") + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asNewSubscriptionUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - newSubscriptionUnitWithPercent.getOrThrow("newSubscriptionUnitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asNewSubscriptionPackageWithAllocation(): - NewSubscriptionPackageWithAllocationPrice = - newSubscriptionPackageWithAllocation.getOrThrow( - "newSubscriptionPackageWithAllocation" - ) + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") - fun asNewSubscriptionTierWithProration(): NewSubscriptionTierWithProrationPrice = - newSubscriptionTierWithProration.getOrThrow("newSubscriptionTierWithProration") + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") - fun asNewSubscriptionUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - newSubscriptionUnitWithProration.getOrThrow("newSubscriptionUnitWithProration") + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") - fun asNewSubscriptionGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - newSubscriptionGroupedAllocation.getOrThrow("newSubscriptionGroupedAllocation") + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") - fun asNewSubscriptionGroupedWithProratedMinimum(): - NewSubscriptionGroupedWithProratedMinimumPrice = - newSubscriptionGroupedWithProratedMinimum.getOrThrow( - "newSubscriptionGroupedWithProratedMinimum" - ) + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asNewSubscriptionBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - newSubscriptionBulkWithProration.getOrThrow("newSubscriptionBulkWithProration") + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") - fun asNewSubscriptionScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - newSubscriptionScalableMatrixWithUnitPricing.getOrThrow( - "newSubscriptionScalableMatrixWithUnitPricing" - ) + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asNewSubscriptionScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - newSubscriptionScalableMatrixWithTieredPricing.getOrThrow( - "newSubscriptionScalableMatrixWithTieredPricing" - ) + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asNewSubscriptionCumulativeGroupedBulk(): - NewSubscriptionCumulativeGroupedBulkPrice = - newSubscriptionCumulativeGroupedBulk.getOrThrow( - "newSubscriptionCumulativeGroupedBulk" - ) + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asNewSubscriptionMaxGroupTieredPackage(): - NewSubscriptionMaxGroupTieredPackagePrice = - newSubscriptionMaxGroupTieredPackage.getOrThrow( - "newSubscriptionMaxGroupTieredPackage" - ) + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asNewSubscriptionGroupedWithMeteredMinimum(): - NewSubscriptionGroupedWithMeteredMinimumPrice = - newSubscriptionGroupedWithMeteredMinimum.getOrThrow( - "newSubscriptionGroupedWithMeteredMinimum" - ) + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - fun asNewSubscriptionMatrixWithDisplayName(): - NewSubscriptionMatrixWithDisplayNamePrice = - newSubscriptionMatrixWithDisplayName.getOrThrow( - "newSubscriptionMatrixWithDisplayName" - ) + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asNewSubscriptionGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - newSubscriptionGroupedTieredPackage.getOrThrow( - "newSubscriptionGroupedTieredPackage" - ) + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newSubscriptionUnit != null -> - visitor.visitNewSubscriptionUnit(newSubscriptionUnit) - newSubscriptionPackage != null -> - visitor.visitNewSubscriptionPackage(newSubscriptionPackage) - newSubscriptionMatrix != null -> - visitor.visitNewSubscriptionMatrix(newSubscriptionMatrix) - newSubscriptionTiered != null -> - visitor.visitNewSubscriptionTiered(newSubscriptionTiered) - newSubscriptionTieredBps != null -> - visitor.visitNewSubscriptionTieredBps(newSubscriptionTieredBps) - newSubscriptionBps != null -> - visitor.visitNewSubscriptionBps(newSubscriptionBps) - newSubscriptionBulkBps != null -> - visitor.visitNewSubscriptionBulkBps(newSubscriptionBulkBps) - newSubscriptionBulk != null -> - visitor.visitNewSubscriptionBulk(newSubscriptionBulk) - newSubscriptionThresholdTotalAmount != null -> - visitor.visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount - ) - newSubscriptionTieredPackage != null -> - visitor.visitNewSubscriptionTieredPackage(newSubscriptionTieredPackage) - newSubscriptionTieredWithMinimum != null -> - visitor.visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum - ) - newSubscriptionUnitWithPercent != null -> - visitor.visitNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent) - newSubscriptionPackageWithAllocation != null -> - visitor.visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - newSubscriptionTierWithProration != null -> - visitor.visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration - ) - newSubscriptionUnitWithProration != null -> - visitor.visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration - ) - newSubscriptionGroupedAllocation != null -> - visitor.visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation - ) - newSubscriptionGroupedWithProratedMinimum != null -> - visitor.visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - newSubscriptionBulkWithProration != null -> - visitor.visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration - ) - newSubscriptionScalableMatrixWithUnitPricing != null -> - visitor.visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing - ) - newSubscriptionScalableMatrixWithTieredPricing != null -> - visitor.visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing - ) - newSubscriptionCumulativeGroupedBulk != null -> - visitor.visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk - ) - newSubscriptionMaxGroupTieredPackage != null -> - visitor.visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage - ) - newSubscriptionGroupedWithMeteredMinimum != null -> - visitor.visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum - ) - newSubscriptionMatrixWithDisplayName != null -> - visitor.visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName - ) - newSubscriptionGroupedTieredPackage != null -> - visitor.visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + tieredBps != null -> visitor.visitTieredBps(tieredBps) + bps != null -> visitor.visitBps(bps) + bulkBps != null -> visitor.visitBulkBps(bulkBps) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) else -> visitor.unknown(_json) } @@ -72726,165 +67155,127 @@ private constructor( } accept( - object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) { - newSubscriptionUnit.validate() + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() } - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) { - newSubscriptionPackage.validate() + override fun visitPackage(package_: Package) { + package_.validate() } - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) { - newSubscriptionMatrix.validate() + override fun visitMatrix(matrix: Matrix) { + matrix.validate() } - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) { - newSubscriptionTiered.validate() + override fun visitTiered(tiered: Tiered) { + tiered.validate() } - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) { - newSubscriptionTieredBps.validate() + override fun visitTieredBps(tieredBps: TieredBps) { + tieredBps.validate() } - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) { - newSubscriptionBps.validate() + override fun visitBps(bps: Bps) { + bps.validate() } - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) { - newSubscriptionBulkBps.validate() + override fun visitBulkBps(bulkBps: BulkBps) { + bulkBps.validate() } - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) { - newSubscriptionBulk.validate() + override fun visitBulk(bulk: Bulk) { + bulk.validate() } - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount ) { - newSubscriptionThresholdTotalAmount.validate() + thresholdTotalAmount.validate() } - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) { - newSubscriptionTieredPackage.validate() + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() } - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - newSubscriptionTieredWithMinimum.validate() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() } - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - newSubscriptionUnitWithPercent.validate() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() } - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation ) { - newSubscriptionPackageWithAllocation.validate() + packageWithAllocation.validate() } - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration ) { - newSubscriptionTierWithProration.validate() + tieredWithProration.validate() } - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - newSubscriptionUnitWithProration.validate() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() } - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - newSubscriptionGroupedAllocation.validate() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() } - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { - newSubscriptionGroupedWithProratedMinimum.validate() + groupedWithProratedMinimum.validate() } - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - newSubscriptionBulkWithProration.validate() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() } - override fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { - newSubscriptionScalableMatrixWithUnitPricing.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { - newSubscriptionScalableMatrixWithTieredPricing.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk ) { - newSubscriptionCumulativeGroupedBulk.validate() + cumulativeGroupedBulk.validate() } - override fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage ) { - newSubscriptionMaxGroupTieredPackage.validate() + maxGroupTieredPackage.validate() } - override fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { - newSubscriptionGroupedWithMeteredMinimum.validate() + groupedWithMeteredMinimum.validate() } - override fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName ) { - newSubscriptionMatrixWithDisplayName.validate() + matrixWithDisplayName.validate() } - override fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage ) { - newSubscriptionGroupedTieredPackage.validate() + groupedTieredPackage.validate() } } ) @@ -72909,115 +67300,83 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) = newSubscriptionUnit.validity() - - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) = newSubscriptionPackage.validity() - - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) = newSubscriptionMatrix.validity() - - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) = newSubscriptionTiered.validity() - - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = newSubscriptionTieredBps.validity() - - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) = newSubscriptionBps.validity() - - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) = newSubscriptionBulkBps.validity() - - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) = newSubscriptionBulk.validity() - - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice - ) = newSubscriptionThresholdTotalAmount.validity() - - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = newSubscriptionTieredPackage.validity() - - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = newSubscriptionTieredWithMinimum.validity() - - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = newSubscriptionUnitWithPercent.validity() - - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice - ) = newSubscriptionPackageWithAllocation.validity() - - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = newSubscriptionTierWithProration.validity() - - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = newSubscriptionUnitWithProration.validity() - - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = newSubscriptionGroupedAllocation.validity() - - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = newSubscriptionGroupedWithProratedMinimum.validity() - - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = newSubscriptionBulkWithProration.validity() - - override fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = newSubscriptionScalableMatrixWithUnitPricing.validity() - - override fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = newSubscriptionScalableMatrixWithTieredPricing.validity() - - override fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice - ) = newSubscriptionCumulativeGroupedBulk.validity() - - override fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice - ) = newSubscriptionMaxGroupTieredPackage.validity() - - override fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = newSubscriptionGroupedWithMeteredMinimum.validity() - - override fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice - ) = newSubscriptionMatrixWithDisplayName.validity() - - override fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice - ) = newSubscriptionGroupedTieredPackage.validity() + override fun 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 visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() + + override fun visitBulk(bulk: Bulk) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -73028,215 +67387,141 @@ private constructor( return true } - return /* spotless:off */ other is Price && newSubscriptionUnit == other.newSubscriptionUnit && newSubscriptionPackage == other.newSubscriptionPackage && newSubscriptionMatrix == other.newSubscriptionMatrix && newSubscriptionTiered == other.newSubscriptionTiered && newSubscriptionTieredBps == other.newSubscriptionTieredBps && newSubscriptionBps == other.newSubscriptionBps && newSubscriptionBulkBps == other.newSubscriptionBulkBps && newSubscriptionBulk == other.newSubscriptionBulk && newSubscriptionThresholdTotalAmount == other.newSubscriptionThresholdTotalAmount && newSubscriptionTieredPackage == other.newSubscriptionTieredPackage && newSubscriptionTieredWithMinimum == other.newSubscriptionTieredWithMinimum && newSubscriptionUnitWithPercent == other.newSubscriptionUnitWithPercent && newSubscriptionPackageWithAllocation == other.newSubscriptionPackageWithAllocation && newSubscriptionTierWithProration == other.newSubscriptionTierWithProration && newSubscriptionUnitWithProration == other.newSubscriptionUnitWithProration && newSubscriptionGroupedAllocation == other.newSubscriptionGroupedAllocation && newSubscriptionGroupedWithProratedMinimum == other.newSubscriptionGroupedWithProratedMinimum && newSubscriptionBulkWithProration == other.newSubscriptionBulkWithProration && newSubscriptionScalableMatrixWithUnitPricing == other.newSubscriptionScalableMatrixWithUnitPricing && newSubscriptionScalableMatrixWithTieredPricing == other.newSubscriptionScalableMatrixWithTieredPricing && newSubscriptionCumulativeGroupedBulk == other.newSubscriptionCumulativeGroupedBulk && newSubscriptionMaxGroupTieredPackage == other.newSubscriptionMaxGroupTieredPackage && newSubscriptionGroupedWithMeteredMinimum == other.newSubscriptionGroupedWithMeteredMinimum && newSubscriptionMatrixWithDisplayName == other.newSubscriptionMatrixWithDisplayName && newSubscriptionGroupedTieredPackage == other.newSubscriptionGroupedTieredPackage /* spotless:on */ + 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 /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newSubscriptionUnit, newSubscriptionPackage, newSubscriptionMatrix, newSubscriptionTiered, newSubscriptionTieredBps, newSubscriptionBps, newSubscriptionBulkBps, newSubscriptionBulk, newSubscriptionThresholdTotalAmount, newSubscriptionTieredPackage, newSubscriptionTieredWithMinimum, newSubscriptionUnitWithPercent, newSubscriptionPackageWithAllocation, newSubscriptionTierWithProration, newSubscriptionUnitWithProration, newSubscriptionGroupedAllocation, newSubscriptionGroupedWithProratedMinimum, newSubscriptionBulkWithProration, newSubscriptionScalableMatrixWithUnitPricing, newSubscriptionScalableMatrixWithTieredPricing, newSubscriptionCumulativeGroupedBulk, newSubscriptionMaxGroupTieredPackage, newSubscriptionGroupedWithMeteredMinimum, newSubscriptionMatrixWithDisplayName, newSubscriptionGroupedTieredPackage) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, bulkWithProration, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, maxGroupTieredPackage, groupedWithMeteredMinimum, matrixWithDisplayName, groupedTieredPackage) /* spotless:on */ override fun toString(): String = when { - newSubscriptionUnit != null -> "Price{newSubscriptionUnit=$newSubscriptionUnit}" - newSubscriptionPackage != null -> - "Price{newSubscriptionPackage=$newSubscriptionPackage}" - newSubscriptionMatrix != null -> - "Price{newSubscriptionMatrix=$newSubscriptionMatrix}" - newSubscriptionTiered != null -> - "Price{newSubscriptionTiered=$newSubscriptionTiered}" - newSubscriptionTieredBps != null -> - "Price{newSubscriptionTieredBps=$newSubscriptionTieredBps}" - newSubscriptionBps != null -> "Price{newSubscriptionBps=$newSubscriptionBps}" - newSubscriptionBulkBps != null -> - "Price{newSubscriptionBulkBps=$newSubscriptionBulkBps}" - newSubscriptionBulk != null -> "Price{newSubscriptionBulk=$newSubscriptionBulk}" - newSubscriptionThresholdTotalAmount != null -> - "Price{newSubscriptionThresholdTotalAmount=$newSubscriptionThresholdTotalAmount}" - newSubscriptionTieredPackage != null -> - "Price{newSubscriptionTieredPackage=$newSubscriptionTieredPackage}" - newSubscriptionTieredWithMinimum != null -> - "Price{newSubscriptionTieredWithMinimum=$newSubscriptionTieredWithMinimum}" - newSubscriptionUnitWithPercent != null -> - "Price{newSubscriptionUnitWithPercent=$newSubscriptionUnitWithPercent}" - newSubscriptionPackageWithAllocation != null -> - "Price{newSubscriptionPackageWithAllocation=$newSubscriptionPackageWithAllocation}" - newSubscriptionTierWithProration != null -> - "Price{newSubscriptionTierWithProration=$newSubscriptionTierWithProration}" - newSubscriptionUnitWithProration != null -> - "Price{newSubscriptionUnitWithProration=$newSubscriptionUnitWithProration}" - newSubscriptionGroupedAllocation != null -> - "Price{newSubscriptionGroupedAllocation=$newSubscriptionGroupedAllocation}" - newSubscriptionGroupedWithProratedMinimum != null -> - "Price{newSubscriptionGroupedWithProratedMinimum=$newSubscriptionGroupedWithProratedMinimum}" - newSubscriptionBulkWithProration != null -> - "Price{newSubscriptionBulkWithProration=$newSubscriptionBulkWithProration}" - newSubscriptionScalableMatrixWithUnitPricing != null -> - "Price{newSubscriptionScalableMatrixWithUnitPricing=$newSubscriptionScalableMatrixWithUnitPricing}" - newSubscriptionScalableMatrixWithTieredPricing != null -> - "Price{newSubscriptionScalableMatrixWithTieredPricing=$newSubscriptionScalableMatrixWithTieredPricing}" - newSubscriptionCumulativeGroupedBulk != null -> - "Price{newSubscriptionCumulativeGroupedBulk=$newSubscriptionCumulativeGroupedBulk}" - newSubscriptionMaxGroupTieredPackage != null -> - "Price{newSubscriptionMaxGroupTieredPackage=$newSubscriptionMaxGroupTieredPackage}" - newSubscriptionGroupedWithMeteredMinimum != null -> - "Price{newSubscriptionGroupedWithMeteredMinimum=$newSubscriptionGroupedWithMeteredMinimum}" - newSubscriptionMatrixWithDisplayName != null -> - "Price{newSubscriptionMatrixWithDisplayName=$newSubscriptionMatrixWithDisplayName}" - newSubscriptionGroupedTieredPackage != null -> - "Price{newSubscriptionGroupedTieredPackage=$newSubscriptionGroupedTieredPackage}" + 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}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } companion object { - @JvmStatic - fun ofNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice) = - Price(newSubscriptionUnit = newSubscriptionUnit) + @JvmStatic fun ofUnit(unit: Unit) = Price(unit = unit) - @JvmStatic - fun ofNewSubscriptionPackage(newSubscriptionPackage: NewSubscriptionPackagePrice) = - Price(newSubscriptionPackage = newSubscriptionPackage) + @JvmStatic fun ofPackage(package_: Package) = Price(package_ = package_) - @JvmStatic - fun ofNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice) = - Price(newSubscriptionMatrix = newSubscriptionMatrix) + @JvmStatic fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) - @JvmStatic - fun ofNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice) = - Price(newSubscriptionTiered = newSubscriptionTiered) + @JvmStatic fun ofTiered(tiered: Tiered) = Price(tiered = tiered) - @JvmStatic - fun ofNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = Price(newSubscriptionTieredBps = newSubscriptionTieredBps) + @JvmStatic fun ofTieredBps(tieredBps: TieredBps) = Price(tieredBps = tieredBps) - @JvmStatic - fun ofNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice) = - Price(newSubscriptionBps = newSubscriptionBps) + @JvmStatic fun ofBps(bps: Bps) = Price(bps = bps) - @JvmStatic - fun ofNewSubscriptionBulkBps(newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice) = - Price(newSubscriptionBulkBps = newSubscriptionBulkBps) + @JvmStatic fun ofBulkBps(bulkBps: BulkBps) = Price(bulkBps = bulkBps) - @JvmStatic - fun ofNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice) = - Price(newSubscriptionBulk = newSubscriptionBulk) + @JvmStatic fun ofBulk(bulk: Bulk) = Price(bulk = bulk) @JvmStatic - fun ofNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(newSubscriptionThresholdTotalAmount = newSubscriptionThresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + Price(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = Price(newSubscriptionTieredPackage = newSubscriptionTieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + Price(tieredPackage = tieredPackage) @JvmStatic - fun ofNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = Price(newSubscriptionTieredWithMinimum = newSubscriptionTieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = Price(newSubscriptionUnitWithPercent = newSubscriptionUnitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + Price(unitWithPercent = unitWithPercent) @JvmStatic - fun ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = - Price( - newSubscriptionPackageWithAllocation = newSubscriptionPackageWithAllocation - ) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(newSubscriptionTierWithProration = newSubscriptionTierWithProration) + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) @JvmStatic - fun ofNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = Price(newSubscriptionUnitWithProration = newSubscriptionUnitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + Price(unitWithProration = unitWithProration) @JvmStatic - fun ofNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = Price(newSubscriptionGroupedAllocation = newSubscriptionGroupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + Price(groupedAllocation = groupedAllocation) @JvmStatic - fun ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = - Price( - newSubscriptionGroupedWithProratedMinimum = - newSubscriptionGroupedWithProratedMinimum - ) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = Price(newSubscriptionBulkWithProration = newSubscriptionBulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + Price(bulkWithProration = bulkWithProration) @JvmStatic - fun ofNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = - Price( - newSubscriptionScalableMatrixWithUnitPricing = - newSubscriptionScalableMatrixWithUnitPricing - ) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic - fun ofNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = - Price( - newSubscriptionScalableMatrixWithTieredPricing = - newSubscriptionScalableMatrixWithTieredPricing - ) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = - Price( - newSubscriptionCumulativeGroupedBulk = newSubscriptionCumulativeGroupedBulk - ) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + Price(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic - fun ofNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = - Price( - newSubscriptionMaxGroupTieredPackage = newSubscriptionMaxGroupTieredPackage - ) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + Price(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic - fun ofNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = - Price( - newSubscriptionGroupedWithMeteredMinimum = - newSubscriptionGroupedWithMeteredMinimum - ) + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = - Price( - newSubscriptionMatrixWithDisplayName = newSubscriptionMatrixWithDisplayName - ) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(newSubscriptionGroupedTieredPackage = newSubscriptionGroupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + Price(groupedTieredPackage = groupedTieredPackage) } /** @@ -73244,99 +67529,63 @@ private constructor( */ interface Visitor { - fun visitNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ): T + fun visitPackage(package_: Package): T - fun visitNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ): T + fun visitTieredBps(tieredBps: TieredBps): T - fun visitNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice): T + fun visitBps(bps: Bps): T - fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ): T + fun visitBulkBps(bulkBps: BulkBps): T - fun visitNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice): T + fun visitBulk(bulk: Bulk): T - fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T - fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T - fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T - fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T - fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T - fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T - fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -73362,221 +67611,138 @@ private constructor( when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionUnit = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(package_ = it, _json = json) + } ?: Price(_json = json) } "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionMatrix = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) } "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } "tiered_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredBps = it, _json = json) + } ?: Price(_json = json) } "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bps = it, _json = json) + } ?: Price(_json = json) } "bulk_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionBulkBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkBps = it, _json = json) + } ?: Price(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionThresholdTotalAmount = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) } "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredPackage = it, _json = json) + } ?: Price(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredWithMinimum = it, _json = json) + } ?: Price(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionUnitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithPercent = it, _json = json) + } ?: Price(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionPackageWithAllocation = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) } "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTierWithProration = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionUnitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedAllocation = it, _json = json) + } ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionBulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithProration = it, _json = json) + } ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionScalableMatrixWithUnitPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionScalableMatrixWithTieredPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionCumulativeGroupedBulk = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionMaxGroupTieredPackage = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price( - newSubscriptionGroupedWithMeteredMinimum = it, - _json = json, - ) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionMatrixWithDisplayName = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionGroupedTieredPackage = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } } @@ -73592,71 +67758,58 @@ private constructor( provider: SerializerProvider, ) { when { - value.newSubscriptionUnit != null -> - generator.writeObject(value.newSubscriptionUnit) - value.newSubscriptionPackage != null -> - generator.writeObject(value.newSubscriptionPackage) - value.newSubscriptionMatrix != null -> - generator.writeObject(value.newSubscriptionMatrix) - value.newSubscriptionTiered != null -> - generator.writeObject(value.newSubscriptionTiered) - value.newSubscriptionTieredBps != null -> - generator.writeObject(value.newSubscriptionTieredBps) - value.newSubscriptionBps != null -> - generator.writeObject(value.newSubscriptionBps) - value.newSubscriptionBulkBps != null -> - generator.writeObject(value.newSubscriptionBulkBps) - value.newSubscriptionBulk != null -> - generator.writeObject(value.newSubscriptionBulk) - value.newSubscriptionThresholdTotalAmount != null -> - generator.writeObject(value.newSubscriptionThresholdTotalAmount) - value.newSubscriptionTieredPackage != null -> - generator.writeObject(value.newSubscriptionTieredPackage) - value.newSubscriptionTieredWithMinimum != null -> - generator.writeObject(value.newSubscriptionTieredWithMinimum) - value.newSubscriptionUnitWithPercent != null -> - generator.writeObject(value.newSubscriptionUnitWithPercent) - value.newSubscriptionPackageWithAllocation != null -> - generator.writeObject(value.newSubscriptionPackageWithAllocation) - value.newSubscriptionTierWithProration != null -> - generator.writeObject(value.newSubscriptionTierWithProration) - value.newSubscriptionUnitWithProration != null -> - generator.writeObject(value.newSubscriptionUnitWithProration) - value.newSubscriptionGroupedAllocation != null -> - generator.writeObject(value.newSubscriptionGroupedAllocation) - value.newSubscriptionGroupedWithProratedMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithProratedMinimum) - value.newSubscriptionBulkWithProration != null -> - generator.writeObject(value.newSubscriptionBulkWithProration) - value.newSubscriptionScalableMatrixWithUnitPricing != null -> - generator.writeObject( - value.newSubscriptionScalableMatrixWithUnitPricing - ) - value.newSubscriptionScalableMatrixWithTieredPricing != null -> - generator.writeObject( - value.newSubscriptionScalableMatrixWithTieredPricing - ) - value.newSubscriptionCumulativeGroupedBulk != null -> - generator.writeObject(value.newSubscriptionCumulativeGroupedBulk) - value.newSubscriptionMaxGroupTieredPackage != null -> - generator.writeObject(value.newSubscriptionMaxGroupTieredPackage) - value.newSubscriptionGroupedWithMeteredMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithMeteredMinimum) - value.newSubscriptionMatrixWithDisplayName != null -> - generator.writeObject(value.newSubscriptionMatrixWithDisplayName) - value.newSubscriptionGroupedTieredPackage != null -> - generator.writeObject(value.newSubscriptionGroupedTieredPackage) + 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._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - class NewSubscriptionUnitPrice + class Unit private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitConfig: JsonField, private val billableMetricId: JsonField, @@ -73683,7 +67836,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -73764,11 +67917,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -73909,16 +68066,6 @@ private constructor( */ @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]. * @@ -74064,14 +68211,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitPrice]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` @@ -74079,12 +68224,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitPrice]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -74104,27 +68249,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionUnitPrice: NewSubscriptionUnitPrice) = apply { - cadence = newSubscriptionUnitPrice.cadence - itemId = newSubscriptionUnitPrice.itemId - modelType = newSubscriptionUnitPrice.modelType - name = newSubscriptionUnitPrice.name - unitConfig = newSubscriptionUnitPrice.unitConfig - billableMetricId = newSubscriptionUnitPrice.billableMetricId - billedInAdvance = newSubscriptionUnitPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitPrice.conversionRate - currency = newSubscriptionUnitPrice.currency - externalPriceId = newSubscriptionUnitPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitPrice.metadata - referenceId = newSubscriptionUnitPrice.referenceId - additionalProperties = - newSubscriptionUnitPrice.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + currency = unit.currency + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -74151,18 +68293,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -74496,7 +68639,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitPrice]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -74504,18 +68647,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitPrice = - NewSubscriptionUnitPrice( + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitConfig", unitConfig), billableMetricId, @@ -74535,14 +68677,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitPrice = apply { + fun validate(): Unit = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitConfig().validate() billableMetricId() @@ -74577,7 +68723,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -74751,135 +68897,6 @@ private constructor( 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 UNIT = of("unit") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT - } - - /** - * 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 { - UNIT, - /** - * 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) { - UNIT -> Value.UNIT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT -> Known.UNIT - 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 UnitConfig private constructor( private val unitAmount: JsonField, @@ -75889,7 +69906,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Unit && 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 && currency == other.currency && 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 */ @@ -75899,14 +69916,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionPackagePrice + class Package private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageConfig: JsonField, private val billableMetricId: JsonField, @@ -75933,7 +69950,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -76014,11 +70031,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -76159,16 +70180,6 @@ private constructor( */ @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]. * @@ -76314,14 +70325,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionPackagePrice]. + * Returns a mutable builder for constructing an instance of [Package]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` @@ -76329,12 +70338,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionPackagePrice]. */ + /** A builder for [Package]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package") private var name: JsonField? = null private var packageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -76354,29 +70363,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionPackagePrice: NewSubscriptionPackagePrice) = - apply { - cadence = newSubscriptionPackagePrice.cadence - itemId = newSubscriptionPackagePrice.itemId - modelType = newSubscriptionPackagePrice.modelType - name = newSubscriptionPackagePrice.name - packageConfig = newSubscriptionPackagePrice.packageConfig - billableMetricId = newSubscriptionPackagePrice.billableMetricId - billedInAdvance = newSubscriptionPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionPackagePrice.conversionRate - currency = newSubscriptionPackagePrice.currency - externalPriceId = newSubscriptionPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionPackagePrice.metadata - referenceId = newSubscriptionPackagePrice.referenceId - additionalProperties = - newSubscriptionPackagePrice.additionalProperties.toMutableMap() - } + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + currency = package_.currency + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -76402,18 +70407,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -76748,7 +70754,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionPackagePrice]. + * Returns an immutable instance of [Package]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -76756,18 +70762,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionPackagePrice = - NewSubscriptionPackagePrice( + fun build(): Package = + Package( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageConfig", packageConfig), billableMetricId, @@ -76787,14 +70792,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionPackagePrice = apply { + fun validate(): Package = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageConfig().validate() billableMetricId() @@ -76829,7 +70838,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -77003,135 +71012,6 @@ private constructor( 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 PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * 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 { - PACKAGE, - /** - * 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) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - 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 PackageConfig private constructor( private val packageAmount: JsonField, @@ -78192,7 +72072,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Package && 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 && currency == other.currency && 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 */ @@ -78202,15 +72082,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Package{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMatrixPrice + class Matrix private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -78239,7 +72119,7 @@ private constructor( matrixConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -78324,11 +72204,15 @@ private constructor( fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -78472,16 +72356,6 @@ private constructor( @ExcludeMissing fun _matrixConfig(): JsonField = matrixConfig - /** - * 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]. * @@ -78617,28 +72491,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMatrixPrice]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMatrixPrice]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -78657,29 +72529,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionMatrixPrice: NewSubscriptionMatrixPrice) = - apply { - cadence = newSubscriptionMatrixPrice.cadence - itemId = newSubscriptionMatrixPrice.itemId - matrixConfig = newSubscriptionMatrixPrice.matrixConfig - modelType = newSubscriptionMatrixPrice.modelType - name = newSubscriptionMatrixPrice.name - billableMetricId = newSubscriptionMatrixPrice.billableMetricId - billedInAdvance = newSubscriptionMatrixPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixPrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixPrice.conversionRate - currency = newSubscriptionMatrixPrice.currency - externalPriceId = newSubscriptionMatrixPrice.externalPriceId - fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionMatrixPrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixPrice.metadata - referenceId = newSubscriptionMatrixPrice.referenceId - additionalProperties = - newSubscriptionMatrixPrice.additionalProperties.toMutableMap() - } + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + currency = matrix.currency + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -78719,18 +72587,19 @@ private constructor( this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -79051,7 +72920,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMatrixPrice]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -79060,18 +72929,17 @@ private constructor( * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMatrixPrice = - NewSubscriptionMatrixPrice( + fun build(): Matrix = + Matrix( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -79090,7 +72958,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMatrixPrice = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -79098,7 +72966,11 @@ private constructor( cadence().validate() itemId() matrixConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -79133,7 +73005,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -79851,135 +73723,6 @@ private constructor( "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -80818,7 +74561,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Matrix && 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 && currency == other.currency && 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 */ @@ -80828,14 +74571,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Matrix{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredPrice + class Tiered private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredConfig: JsonField, private val billableMetricId: JsonField, @@ -80862,7 +74605,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -80943,11 +74686,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -81088,16 +74835,6 @@ private constructor( */ @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]. * @@ -81243,14 +74980,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredPrice]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` @@ -81258,12 +74993,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredPrice]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered") private var name: JsonField? = null private var tieredConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -81283,29 +75018,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionTieredPrice: NewSubscriptionTieredPrice) = - apply { - cadence = newSubscriptionTieredPrice.cadence - itemId = newSubscriptionTieredPrice.itemId - modelType = newSubscriptionTieredPrice.modelType - name = newSubscriptionTieredPrice.name - tieredConfig = newSubscriptionTieredPrice.tieredConfig - billableMetricId = newSubscriptionTieredPrice.billableMetricId - billedInAdvance = newSubscriptionTieredPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPrice.conversionRate - currency = newSubscriptionTieredPrice.currency - externalPriceId = newSubscriptionTieredPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPrice.metadata - referenceId = newSubscriptionTieredPrice.referenceId - additionalProperties = - newSubscriptionTieredPrice.additionalProperties.toMutableMap() - } + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + currency = tiered.currency + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -81331,18 +75062,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -81677,7 +75409,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredPrice]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -81685,18 +75417,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredPrice = - NewSubscriptionTieredPrice( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredConfig", tieredConfig), billableMetricId, @@ -81716,14 +75447,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredPrice = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredConfig().validate() billableMetricId() @@ -81758,7 +75493,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -81932,135 +75667,6 @@ private constructor( 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 = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * 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, - /** - * 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 -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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 -> Known.TIERED - 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 TieredConfig private constructor( private val tiers: JsonField>, @@ -83362,7 +76968,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tiered && 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 && currency == other.currency && 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 */ @@ -83372,14 +76978,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredBpsPrice + class TieredBps private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredBpsConfig: JsonField, private val billableMetricId: JsonField, @@ -83406,7 +77012,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -83487,11 +77093,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -83633,16 +77243,6 @@ private constructor( */ @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]. * @@ -83788,14 +77388,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredBpsPrice]. + * Returns a mutable builder for constructing an instance of [TieredBps]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` @@ -83803,12 +77401,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredBpsPrice]. */ + /** A builder for [TieredBps]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_bps") private var name: JsonField? = null private var tieredBpsConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -83828,29 +77426,24 @@ private constructor( 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 - currency = newSubscriptionTieredBpsPrice.currency - externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredBpsPrice.metadata - referenceId = newSubscriptionTieredBpsPrice.referenceId - additionalProperties = - newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() + internal fun from(tieredBps: TieredBps) = apply { + cadence = tieredBps.cadence + itemId = tieredBps.itemId + modelType = tieredBps.modelType + name = tieredBps.name + tieredBpsConfig = tieredBps.tieredBpsConfig + billableMetricId = tieredBps.billableMetricId + billedInAdvance = tieredBps.billedInAdvance + billingCycleConfiguration = tieredBps.billingCycleConfiguration + conversionRate = tieredBps.conversionRate + currency = tieredBps.currency + externalPriceId = tieredBps.externalPriceId + fixedPriceQuantity = tieredBps.fixedPriceQuantity + invoiceGroupingKey = tieredBps.invoiceGroupingKey + invoicingCycleConfiguration = tieredBps.invoicingCycleConfiguration + metadata = tieredBps.metadata + referenceId = tieredBps.referenceId + additionalProperties = tieredBps.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -83877,18 +77470,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -84223,7 +77817,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredBpsPrice]. + * Returns an immutable instance of [TieredBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -84231,18 +77825,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice( + fun build(): TieredBps = + TieredBps( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredBpsConfig", tieredBpsConfig), billableMetricId, @@ -84262,14 +77855,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredBpsPrice = apply { + fun validate(): TieredBps = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredBpsConfig().validate() billableMetricId() @@ -84304,7 +77901,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -84478,135 +78075,6 @@ private constructor( 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() - } - class TieredBpsConfig private constructor( private val tiers: JsonField>, @@ -85950,7 +79418,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBps && 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 && currency == other.currency && 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 */ @@ -85960,15 +79428,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredBps{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBpsPrice + class Bps private constructor( private val bpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -85997,7 +79465,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -86082,11 +79550,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -86230,16 +79702,6 @@ private constructor( */ @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]. * @@ -86375,28 +79837,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBpsPrice]. + * Returns a mutable builder for constructing an instance of [Bps]. * * The following fields are required: * ```java * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBpsPrice]. */ + /** A builder for [Bps]. */ 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 modelType: JsonValue = JsonValue.from("bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -86415,27 +79875,24 @@ private constructor( 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 - currency = newSubscriptionBpsPrice.currency - externalPriceId = newSubscriptionBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBpsPrice.metadata - referenceId = newSubscriptionBpsPrice.referenceId - additionalProperties = - newSubscriptionBpsPrice.additionalProperties.toMutableMap() + internal fun from(bps: Bps) = apply { + bpsConfig = bps.bpsConfig + cadence = bps.cadence + itemId = bps.itemId + modelType = bps.modelType + name = bps.name + billableMetricId = bps.billableMetricId + billedInAdvance = bps.billedInAdvance + billingCycleConfiguration = bps.billingCycleConfiguration + conversionRate = bps.conversionRate + currency = bps.currency + externalPriceId = bps.externalPriceId + fixedPriceQuantity = bps.fixedPriceQuantity + invoiceGroupingKey = bps.invoiceGroupingKey + invoicingCycleConfiguration = bps.invoicingCycleConfiguration + metadata = bps.metadata + referenceId = bps.referenceId + additionalProperties = bps.additionalProperties.toMutableMap() } fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) @@ -86475,18 +79932,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -86807,7 +80265,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBpsPrice]. + * Returns an immutable instance of [Bps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -86816,18 +80274,17 @@ private constructor( * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBpsPrice = - NewSubscriptionBpsPrice( + fun build(): Bps = + Bps( checkRequired("bpsConfig", bpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -86846,7 +80303,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBpsPrice = apply { + fun validate(): Bps = apply { if (validated) { return@apply } @@ -86854,7 +80311,11 @@ private constructor( bpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -86889,7 +80350,7 @@ private constructor( (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -87280,135 +80741,6 @@ private constructor( 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -88247,7 +81579,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bps && 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 && currency == other.currency && 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 */ @@ -88257,15 +81589,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bps{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkBpsPrice + class BulkBps private constructor( private val bulkBpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -88294,7 +81626,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -88379,11 +81711,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -88527,16 +81863,6 @@ private constructor( */ @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]. * @@ -88672,28 +81998,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of [BulkBps]. * * The following fields are required: * ```java * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkBpsPrice]. */ + /** A builder for [BulkBps]. */ class Builder internal constructor() { private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -88712,29 +82036,25 @@ 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 - currency = newSubscriptionBulkBpsPrice.currency - externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkBpsPrice.metadata - referenceId = newSubscriptionBulkBpsPrice.referenceId - additionalProperties = - newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() - } + internal fun from(bulkBps: BulkBps) = apply { + bulkBpsConfig = bulkBps.bulkBpsConfig + cadence = bulkBps.cadence + itemId = bulkBps.itemId + modelType = bulkBps.modelType + name = bulkBps.name + billableMetricId = bulkBps.billableMetricId + billedInAdvance = bulkBps.billedInAdvance + billingCycleConfiguration = bulkBps.billingCycleConfiguration + conversionRate = bulkBps.conversionRate + currency = bulkBps.currency + externalPriceId = bulkBps.externalPriceId + fixedPriceQuantity = bulkBps.fixedPriceQuantity + invoiceGroupingKey = bulkBps.invoiceGroupingKey + invoicingCycleConfiguration = bulkBps.invoicingCycleConfiguration + metadata = bulkBps.metadata + referenceId = bulkBps.referenceId + additionalProperties = bulkBps.additionalProperties.toMutableMap() + } fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = bulkBpsConfig(JsonField.of(bulkBpsConfig)) @@ -88774,18 +82094,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -89106,7 +82427,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkBpsPrice]. + * Returns an immutable instance of [BulkBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -89115,18 +82436,17 @@ private constructor( * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( + fun build(): BulkBps = + BulkBps( checkRequired("bulkBpsConfig", bulkBpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -89145,7 +82465,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkBpsPrice = apply { + fun validate(): BulkBps = apply { if (validated) { return@apply } @@ -89153,7 +82473,11 @@ private constructor( bulkBpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -89188,7 +82512,7 @@ private constructor( (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -89820,135 +83144,6 @@ private constructor( 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 BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -90787,7 +83982,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBps && 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 && currency == other.currency && 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 */ @@ -90797,15 +83992,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkBps{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkPrice + class Bulk private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -90834,7 +84029,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -90919,11 +84114,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -91067,16 +84266,6 @@ private constructor( */ @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]. * @@ -91212,28 +84401,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkPrice]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkPrice]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -91252,27 +84439,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionBulkPrice: NewSubscriptionBulkPrice) = apply { - bulkConfig = newSubscriptionBulkPrice.bulkConfig - cadence = newSubscriptionBulkPrice.cadence - itemId = newSubscriptionBulkPrice.itemId - modelType = newSubscriptionBulkPrice.modelType - name = newSubscriptionBulkPrice.name - billableMetricId = newSubscriptionBulkPrice.billableMetricId - billedInAdvance = newSubscriptionBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkPrice.conversionRate - currency = newSubscriptionBulkPrice.currency - externalPriceId = newSubscriptionBulkPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkPrice.metadata - referenceId = newSubscriptionBulkPrice.referenceId - additionalProperties = - newSubscriptionBulkPrice.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + currency = bulk.currency + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() } fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) @@ -91312,18 +84496,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -91644,7 +84829,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkPrice]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -91653,18 +84838,17 @@ private constructor( * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkPrice = - NewSubscriptionBulkPrice( + fun build(): Bulk = + Bulk( checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -91683,7 +84867,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkPrice = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -91691,7 +84875,11 @@ private constructor( bulkConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -91726,7 +84914,7 @@ private constructor( (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -92316,135 +85504,6 @@ private constructor( 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 BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -93283,7 +86342,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bulk && 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 && currency == other.currency && 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 */ @@ -93293,14 +86352,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionThresholdTotalAmountPrice + class ThresholdTotalAmount private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val thresholdTotalAmountConfig: JsonField, private val billableMetricId: JsonField, @@ -93327,7 +86386,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -93409,11 +86468,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -93555,16 +86618,6 @@ private constructor( */ @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]. * @@ -93712,13 +86765,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionThresholdTotalAmountPrice]. + * [ThresholdTotalAmount]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` @@ -93726,12 +86778,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionThresholdTotalAmountPrice]. */ + /** A builder for [ThresholdTotalAmount]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") private var name: JsonField? = null private var thresholdTotalAmountConfig: JsonField? = null @@ -93752,34 +86804,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionThresholdTotalAmountPrice: - NewSubscriptionThresholdTotalAmountPrice - ) = apply { - cadence = newSubscriptionThresholdTotalAmountPrice.cadence - itemId = newSubscriptionThresholdTotalAmountPrice.itemId - modelType = newSubscriptionThresholdTotalAmountPrice.modelType - name = newSubscriptionThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newSubscriptionThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newSubscriptionThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newSubscriptionThresholdTotalAmountPrice.conversionRate - currency = newSubscriptionThresholdTotalAmountPrice.currency - externalPriceId = newSubscriptionThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + currency = thresholdTotalAmount.currency + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newSubscriptionThresholdTotalAmountPrice.metadata - referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId + thresholdTotalAmount.invoicingCycleConfiguration + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId additionalProperties = - newSubscriptionThresholdTotalAmountPrice.additionalProperties - .toMutableMap() + thresholdTotalAmount.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -93806,18 +86850,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -94154,7 +87199,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionThresholdTotalAmountPrice]. + * Returns an immutable instance of [ThresholdTotalAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -94162,18 +87207,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionThresholdTotalAmountPrice = - NewSubscriptionThresholdTotalAmountPrice( + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), billableMetricId, @@ -94193,14 +87237,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -94235,7 +87283,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -94409,135 +87459,6 @@ private constructor( 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 THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * 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 { - THRESHOLD_TOTAL_AMOUNT, - /** - * 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) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - 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 ThresholdTotalAmountConfig @JsonCreator private constructor( @@ -95490,7 +88411,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmount && 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 && currency == other.currency && 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 */ @@ -95500,14 +88421,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredPackagePrice + class TieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredPackageConfig: JsonField, private val billableMetricId: JsonField, @@ -95534,7 +88455,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -95615,11 +88536,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -95761,16 +88686,6 @@ private constructor( */ @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]. * @@ -95916,14 +88831,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [TieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` @@ -95931,12 +88844,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredPackagePrice]. */ + /** A builder for [TieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_package") private var name: JsonField? = null private var tieredPackageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -95956,29 +88869,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionTieredPackagePrice: NewSubscriptionTieredPackagePrice - ) = apply { - cadence = newSubscriptionTieredPackagePrice.cadence - itemId = newSubscriptionTieredPackagePrice.itemId - modelType = newSubscriptionTieredPackagePrice.modelType - name = newSubscriptionTieredPackagePrice.name - tieredPackageConfig = newSubscriptionTieredPackagePrice.tieredPackageConfig - billableMetricId = newSubscriptionTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPackagePrice.conversionRate - currency = newSubscriptionTieredPackagePrice.currency - externalPriceId = newSubscriptionTieredPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPackagePrice.metadata - referenceId = newSubscriptionTieredPackagePrice.referenceId - additionalProperties = - newSubscriptionTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + currency = tieredPackage.currency + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -96005,18 +88913,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -96352,7 +89261,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredPackagePrice]. + * Returns an immutable instance of [TieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -96360,18 +89269,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredPackagePrice = - NewSubscriptionTieredPackagePrice( + fun build(): TieredPackage = + TieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredPackageConfig", tieredPackageConfig), billableMetricId, @@ -96391,14 +89299,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredPackagePrice = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredPackageConfig().validate() billableMetricId() @@ -96433,7 +89345,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -96607,135 +89519,6 @@ private constructor( 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_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * 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_PACKAGE, - /** - * 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_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_PACKAGE -> Known.TIERED_PACKAGE - 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 TieredPackageConfig @JsonCreator private constructor( @@ -97687,7 +90470,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackage && 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 && currency == other.currency && 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 */ @@ -97697,14 +90480,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredPackage{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredWithMinimumPrice + class TieredWithMinimum private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithMinimumConfig: JsonField, private val billableMetricId: JsonField, @@ -97731,7 +90514,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -97812,11 +90595,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -97958,16 +90745,6 @@ private constructor( */ @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]. * @@ -98115,13 +90892,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredWithMinimumPrice]. + * [TieredWithMinimum]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` @@ -98129,12 +90905,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredWithMinimumPrice]. */ + /** A builder for [TieredWithMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var tieredWithMinimumConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -98154,33 +90930,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionTieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice - ) = apply { - cadence = newSubscriptionTieredWithMinimumPrice.cadence - itemId = newSubscriptionTieredWithMinimumPrice.itemId - modelType = newSubscriptionTieredWithMinimumPrice.modelType - name = newSubscriptionTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newSubscriptionTieredWithMinimumPrice.billableMetricId - billedInAdvance = newSubscriptionTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredWithMinimumPrice.conversionRate - currency = newSubscriptionTieredWithMinimumPrice.currency - externalPriceId = newSubscriptionTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredWithMinimumPrice.metadata - referenceId = newSubscriptionTieredWithMinimumPrice.referenceId - additionalProperties = - newSubscriptionTieredWithMinimumPrice.additionalProperties - .toMutableMap() + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + currency = tieredWithMinimum.currency + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -98207,18 +90974,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -98553,7 +91321,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredWithMinimumPrice]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -98561,18 +91329,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredWithMinimumPrice = - NewSubscriptionTieredWithMinimumPrice( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), billableMetricId, @@ -98592,14 +91359,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithMinimumConfig().validate() billableMetricId() @@ -98634,7 +91405,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -98808,135 +91581,6 @@ private constructor( 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_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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 TieredWithMinimumConfig @JsonCreator private constructor( @@ -99889,7 +92533,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithMinimum && 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 && currency == other.currency && 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 */ @@ -99899,14 +92543,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionUnitWithPercentPrice + class UnitWithPercent private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithPercentConfig: JsonField, private val billableMetricId: JsonField, @@ -99933,7 +92577,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -100014,11 +92658,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -100160,16 +92808,6 @@ private constructor( */ @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]. * @@ -100316,14 +92954,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitWithPercentPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` @@ -100331,12 +92967,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitWithPercentPrice]. */ + /** A builder for [UnitWithPercent]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") private var name: JsonField? = null private var unitWithPercentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -100356,30 +92992,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionUnitWithPercentPrice: NewSubscriptionUnitWithPercentPrice - ) = apply { - cadence = newSubscriptionUnitWithPercentPrice.cadence - itemId = newSubscriptionUnitWithPercentPrice.itemId - modelType = newSubscriptionUnitWithPercentPrice.modelType - name = newSubscriptionUnitWithPercentPrice.name - unitWithPercentConfig = - newSubscriptionUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newSubscriptionUnitWithPercentPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithPercentPrice.conversionRate - currency = newSubscriptionUnitWithPercentPrice.currency - externalPriceId = newSubscriptionUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithPercentPrice.metadata - referenceId = newSubscriptionUnitWithPercentPrice.referenceId - additionalProperties = - newSubscriptionUnitWithPercentPrice.additionalProperties.toMutableMap() + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + currency = unitWithPercent.currency + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -100406,18 +93036,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -100752,7 +93383,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitWithPercentPrice]. + * Returns an immutable instance of [UnitWithPercent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -100760,18 +93391,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitWithPercentPrice = - NewSubscriptionUnitWithPercentPrice( + fun build(): UnitWithPercent = + UnitWithPercent( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithPercentConfig", unitWithPercentConfig), billableMetricId, @@ -100791,14 +93421,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitWithPercentPrice = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithPercentConfig().validate() billableMetricId() @@ -100833,7 +93467,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -101007,135 +93641,6 @@ private constructor( 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 UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * 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 { - UNIT_WITH_PERCENT, - /** - * 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) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - 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 UnitWithPercentConfig @JsonCreator private constructor( @@ -102087,7 +94592,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercent && 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 && currency == other.currency && 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 */ @@ -102097,14 +94602,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "UnitWithPercent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionPackageWithAllocationPrice + class PackageWithAllocation private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageWithAllocationConfig: JsonField, private val billableMetricId: JsonField, @@ -102131,7 +94636,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -102213,11 +94718,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -102359,16 +94868,6 @@ private constructor( */ @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]. * @@ -102516,13 +95015,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionPackageWithAllocationPrice]. + * [PackageWithAllocation]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` @@ -102530,12 +95028,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionPackageWithAllocationPrice]. */ + /** A builder for [PackageWithAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") private var name: JsonField? = null private var packageWithAllocationConfig: JsonField? = @@ -102557,35 +95055,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionPackageWithAllocationPrice: - NewSubscriptionPackageWithAllocationPrice - ) = apply { - cadence = newSubscriptionPackageWithAllocationPrice.cadence - itemId = newSubscriptionPackageWithAllocationPrice.itemId - modelType = newSubscriptionPackageWithAllocationPrice.modelType - name = newSubscriptionPackageWithAllocationPrice.name + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name packageWithAllocationConfig = - newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = - newSubscriptionPackageWithAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionPackageWithAllocationPrice.conversionRate - currency = newSubscriptionPackageWithAllocationPrice.currency - externalPriceId = newSubscriptionPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + currency = packageWithAllocation.currency + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionPackageWithAllocationPrice.metadata - referenceId = newSubscriptionPackageWithAllocationPrice.referenceId + packageWithAllocation.invoicingCycleConfiguration + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId additionalProperties = - newSubscriptionPackageWithAllocationPrice.additionalProperties - .toMutableMap() + packageWithAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -102612,18 +95102,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -102960,7 +95451,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionPackageWithAllocationPrice]. + * Returns an immutable instance of [PackageWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -102968,18 +95459,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionPackageWithAllocationPrice = - NewSubscriptionPackageWithAllocationPrice( + fun build(): PackageWithAllocation = + PackageWithAllocation( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "packageWithAllocationConfig", @@ -103002,14 +95492,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageWithAllocationConfig().validate() billableMetricId() @@ -103044,7 +95538,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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 (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -103218,135 +95714,6 @@ private constructor( 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 PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * 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 { - PACKAGE_WITH_ALLOCATION, - /** - * 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) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - 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 PackageWithAllocationConfig @JsonCreator private constructor( @@ -104300,7 +96667,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocation && 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 && currency == other.currency && 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 */ @@ -104310,14 +96677,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTierWithProrationPrice + class TieredWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -104344,7 +96711,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -104426,11 +96793,15 @@ private constructor( 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). + * 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). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -104572,16 +96943,6 @@ private constructor( */ @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]. * @@ -104729,13 +97090,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTierWithProrationPrice]. + * [TieredWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` @@ -104743,12 +97103,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTierWithProrationPrice]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null private var tieredWithProrationConfig: JsonField? = null @@ -104769,33 +97129,26 @@ private constructor( 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 - currency = newSubscriptionTierWithProrationPrice.currency - externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTierWithProrationPrice.invoiceGroupingKey + 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 + currency = tieredWithProration.currency + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionTierWithProrationPrice.metadata - referenceId = newSubscriptionTierWithProrationPrice.referenceId + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId additionalProperties = - newSubscriptionTierWithProrationPrice.additionalProperties - .toMutableMap() + tieredWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -104822,18 +97175,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -105169,7 +97523,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTierWithProrationPrice]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -105177,18 +97531,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, @@ -105208,14 +97561,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTierWithProrationPrice = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithProrationConfig().validate() billableMetricId() @@ -105250,7 +97607,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -105424,135 +97783,6 @@ private constructor( 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( @@ -106505,7 +98735,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 && currency == other.currency && 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 */ @@ -106515,14 +98745,14 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionUnitWithProrationPrice + class UnitWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -106549,7 +98779,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -106630,11 +98860,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -106776,16 +99010,6 @@ private constructor( */ @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]. * @@ -106933,13 +99157,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitWithProrationPrice]. + * [UnitWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` @@ -106947,12 +99170,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitWithProrationPrice]. */ + /** A builder for [UnitWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") private var name: JsonField? = null private var unitWithProrationConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -106972,33 +99195,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionUnitWithProrationPrice: NewSubscriptionUnitWithProrationPrice - ) = apply { - cadence = newSubscriptionUnitWithProrationPrice.cadence - itemId = newSubscriptionUnitWithProrationPrice.itemId - modelType = newSubscriptionUnitWithProrationPrice.modelType - name = newSubscriptionUnitWithProrationPrice.name - unitWithProrationConfig = - newSubscriptionUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newSubscriptionUnitWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithProrationPrice.conversionRate - currency = newSubscriptionUnitWithProrationPrice.currency - externalPriceId = newSubscriptionUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithProrationPrice.metadata - referenceId = newSubscriptionUnitWithProrationPrice.referenceId - additionalProperties = - newSubscriptionUnitWithProrationPrice.additionalProperties - .toMutableMap() + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + currency = unitWithProration.currency + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -107025,18 +99239,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -107371,7 +99586,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitWithProrationPrice]. + * Returns an immutable instance of [UnitWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -107379,18 +99594,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitWithProrationPrice = - NewSubscriptionUnitWithProrationPrice( + fun build(): UnitWithProration = + UnitWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithProrationConfig", unitWithProrationConfig), billableMetricId, @@ -107410,14 +99624,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitWithProrationPrice = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithProrationConfig().validate() billableMetricId() @@ -107452,7 +99670,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -107626,135 +99846,6 @@ private constructor( 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 UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_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 { - UNIT_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) { - UNIT_WITH_PRORATION -> Value.UNIT_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) { - UNIT_WITH_PRORATION -> Known.UNIT_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 UnitWithProrationConfig @JsonCreator private constructor( @@ -108707,7 +100798,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProration && 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 && currency == other.currency && 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 */ @@ -108717,15 +100808,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "UnitWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedAllocationPrice + class GroupedAllocation private constructor( private val cadence: JsonField, private val groupedAllocationConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -108754,7 +100845,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -108840,11 +100931,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -108989,16 +101084,6 @@ private constructor( */ @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]. * @@ -109135,27 +101220,26 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedAllocationPrice]. + * [GroupedAllocation]. * * The following fields are required: * ```java * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedAllocationPrice]. */ + /** A builder for [GroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedAllocationConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -109174,33 +101258,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedAllocationPrice: NewSubscriptionGroupedAllocationPrice - ) = apply { - cadence = newSubscriptionGroupedAllocationPrice.cadence - groupedAllocationConfig = - newSubscriptionGroupedAllocationPrice.groupedAllocationConfig - itemId = newSubscriptionGroupedAllocationPrice.itemId - modelType = newSubscriptionGroupedAllocationPrice.modelType - name = newSubscriptionGroupedAllocationPrice.name - billableMetricId = newSubscriptionGroupedAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedAllocationPrice.conversionRate - currency = newSubscriptionGroupedAllocationPrice.currency - externalPriceId = newSubscriptionGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedAllocationPrice.metadata - referenceId = newSubscriptionGroupedAllocationPrice.referenceId - additionalProperties = - newSubscriptionGroupedAllocationPrice.additionalProperties - .toMutableMap() + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + currency = groupedAllocation.currency + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -109241,18 +101316,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -109573,7 +101649,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionGroupedAllocationPrice]. + * Returns an immutable instance of [GroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -109582,18 +101658,17 @@ private constructor( * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedAllocationPrice = - NewSubscriptionGroupedAllocationPrice( + fun build(): GroupedAllocation = + GroupedAllocation( checkRequired("cadence", cadence), checkRequired("groupedAllocationConfig", groupedAllocationConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -109612,7 +101687,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedAllocationPrice = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -109620,7 +101695,11 @@ private constructor( cadence().validate() groupedAllocationConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -109655,7 +101734,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -109942,135 +102021,6 @@ private constructor( "GroupedAllocationConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * 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 { - GROUPED_ALLOCATION, - /** - * 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) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -110909,7 +102859,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocation && 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 && currency == other.currency && 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 */ @@ -110919,16 +102869,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedWithProratedMinimumPrice + class GroupedWithProratedMinimum private constructor( private val cadence: JsonField, private val groupedWithProratedMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -110958,7 +102908,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -111046,11 +102996,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -111195,16 +103149,6 @@ private constructor( */ @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]. * @@ -111341,21 +103285,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedWithProratedMinimumPrice]. + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedWithProratedMinimumPrice]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -111363,7 +103306,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -111382,41 +103326,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithProratedMinimumPrice: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithProratedMinimumPrice.cadence - groupedWithProratedMinimumConfig = - newSubscriptionGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newSubscriptionGroupedWithProratedMinimumPrice.itemId - modelType = newSubscriptionGroupedWithProratedMinimumPrice.modelType - name = newSubscriptionGroupedWithProratedMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithProratedMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithProratedMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + currency = groupedWithProratedMinimum.currency + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -111464,18 +103397,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -111796,8 +103730,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionGroupedWithProratedMinimumPrice]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -111806,21 +103739,20 @@ private constructor( * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedWithProratedMinimumPrice = - NewSubscriptionGroupedWithProratedMinimumPrice( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithProratedMinimumConfig", groupedWithProratedMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -111839,7 +103771,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -111847,7 +103779,11 @@ private constructor( cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -111882,7 +103818,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -112170,136 +104108,6 @@ private constructor( "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -113138,7 +104946,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimum && 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 && currency == other.currency && 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 */ @@ -113148,15 +104956,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkWithProrationPrice + class BulkWithProration private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -113185,7 +104993,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -113271,11 +105079,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -113420,16 +105232,6 @@ private constructor( */ @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]. * @@ -113566,27 +105368,26 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkWithProrationPrice]. + * [BulkWithProration]. * * The following fields are required: * ```java * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkWithProrationPrice]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -113605,33 +105406,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionBulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig - cadence = newSubscriptionBulkWithProrationPrice.cadence - itemId = newSubscriptionBulkWithProrationPrice.itemId - modelType = newSubscriptionBulkWithProrationPrice.modelType - name = newSubscriptionBulkWithProrationPrice.name - billableMetricId = newSubscriptionBulkWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkWithProrationPrice.conversionRate - currency = newSubscriptionBulkWithProrationPrice.currency - externalPriceId = newSubscriptionBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkWithProrationPrice.metadata - referenceId = newSubscriptionBulkWithProrationPrice.referenceId - additionalProperties = - newSubscriptionBulkWithProrationPrice.additionalProperties - .toMutableMap() + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + currency = bulkWithProration.currency + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = @@ -113672,18 +105464,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -114004,7 +105797,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkWithProrationPrice]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -114013,18 +105806,17 @@ private constructor( * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkWithProrationPrice = - NewSubscriptionBulkWithProrationPrice( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -114043,7 +105835,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkWithProrationPrice = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -114051,7 +105843,11 @@ private constructor( bulkWithProrationConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -114086,7 +105882,9 @@ private constructor( (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -114373,135 +106171,6 @@ private constructor( 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 BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_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 { - BULK_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) { - BULK_WITH_PRORATION -> Value.BULK_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) { - BULK_WITH_PRORATION -> Known.BULK_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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -115340,7 +107009,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkWithProration && 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 && currency == other.currency && 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 */ @@ -115350,14 +107019,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionScalableMatrixWithUnitPricingPrice + class ScalableMatrixWithUnitPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithUnitPricingConfig: JsonField, @@ -115385,7 +107054,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -115468,11 +107137,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -115616,16 +107289,6 @@ private constructor( */ @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]. * @@ -115774,13 +107437,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionScalableMatrixWithUnitPricingPrice]. + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` @@ -115788,12 +107450,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var scalableMatrixWithUnitPricingConfig: JsonField? = @@ -115816,40 +107479,29 @@ private constructor( @JvmSynthetic internal fun from( - newSubscriptionScalableMatrixWithUnitPricingPrice: - NewSubscriptionScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = apply { - cadence = newSubscriptionScalableMatrixWithUnitPricingPrice.cadence - itemId = newSubscriptionScalableMatrixWithUnitPricingPrice.itemId - modelType = newSubscriptionScalableMatrixWithUnitPricingPrice.modelType - name = newSubscriptionScalableMatrixWithUnitPricingPrice.name + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name scalableMatrixWithUnitPricingConfig = - newSubscriptionScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = - newSubscriptionScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = - newSubscriptionScalableMatrixWithUnitPricingPrice.billedInAdvance + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance billingCycleConfiguration = - newSubscriptionScalableMatrixWithUnitPricingPrice - .billingCycleConfiguration - conversionRate = - newSubscriptionScalableMatrixWithUnitPricingPrice.conversionRate - currency = newSubscriptionScalableMatrixWithUnitPricingPrice.currency - externalPriceId = - newSubscriptionScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionScalableMatrixWithUnitPricingPrice.invoiceGroupingKey + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + currency = scalableMatrixWithUnitPricing.currency + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionScalableMatrixWithUnitPricingPrice - .invoicingCycleConfiguration - metadata = newSubscriptionScalableMatrixWithUnitPricingPrice.metadata - referenceId = newSubscriptionScalableMatrixWithUnitPricingPrice.referenceId + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId additionalProperties = - newSubscriptionScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -115876,18 +107528,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -116232,8 +107885,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionScalableMatrixWithUnitPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -116241,18 +107893,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionScalableMatrixWithUnitPricingPrice = - NewSubscriptionScalableMatrixWithUnitPricingPrice( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithUnitPricingConfig", @@ -116275,14 +107926,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionScalableMatrixWithUnitPricingPrice = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -116317,7 +107972,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -116492,139 +108149,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_UNIT_PRICING = - of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - 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 ScalableMatrixWithUnitPricingConfig @JsonCreator private constructor( @@ -117579,7 +109103,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithUnitPricing && 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 && currency == other.currency && 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 */ @@ -117589,14 +109113,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionScalableMatrixWithTieredPricingPrice + class ScalableMatrixWithTieredPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithTieredPricingConfig: JsonField, @@ -117624,7 +109148,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -117707,11 +109231,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -117855,16 +109383,6 @@ private constructor( */ @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]. * @@ -118013,13 +109531,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionScalableMatrixWithTieredPricingPrice]. + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` @@ -118027,12 +109544,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionScalableMatrixWithTieredPricingPrice]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var scalableMatrixWithTieredPricingConfig: JsonField? = @@ -118055,41 +109573,29 @@ private constructor( @JvmSynthetic internal fun from( - newSubscriptionScalableMatrixWithTieredPricingPrice: - NewSubscriptionScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = apply { - cadence = newSubscriptionScalableMatrixWithTieredPricingPrice.cadence - itemId = newSubscriptionScalableMatrixWithTieredPricingPrice.itemId - modelType = newSubscriptionScalableMatrixWithTieredPricingPrice.modelType - name = newSubscriptionScalableMatrixWithTieredPricingPrice.name + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name scalableMatrixWithTieredPricingConfig = - newSubscriptionScalableMatrixWithTieredPricingPrice - .scalableMatrixWithTieredPricingConfig - billableMetricId = - newSubscriptionScalableMatrixWithTieredPricingPrice.billableMetricId - billedInAdvance = - newSubscriptionScalableMatrixWithTieredPricingPrice.billedInAdvance + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance billingCycleConfiguration = - newSubscriptionScalableMatrixWithTieredPricingPrice - .billingCycleConfiguration - conversionRate = - newSubscriptionScalableMatrixWithTieredPricingPrice.conversionRate - currency = newSubscriptionScalableMatrixWithTieredPricingPrice.currency - externalPriceId = - newSubscriptionScalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionScalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionScalableMatrixWithTieredPricingPrice.invoiceGroupingKey + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + currency = scalableMatrixWithTieredPricing.currency + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionScalableMatrixWithTieredPricingPrice - .invoicingCycleConfiguration - metadata = newSubscriptionScalableMatrixWithTieredPricingPrice.metadata - referenceId = - newSubscriptionScalableMatrixWithTieredPricingPrice.referenceId + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId additionalProperties = - newSubscriptionScalableMatrixWithTieredPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -118116,18 +109622,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -118472,8 +109979,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionScalableMatrixWithTieredPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -118481,18 +109987,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionScalableMatrixWithTieredPricingPrice = - NewSubscriptionScalableMatrixWithTieredPricingPrice( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithTieredPricingConfig", @@ -118515,14 +110020,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionScalableMatrixWithTieredPricingPrice = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -118557,7 +110066,10 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -118732,139 +110244,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - 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 ScalableMatrixWithTieredPricingConfig @JsonCreator private constructor( @@ -119822,7 +111201,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithTieredPricing && 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 && currency == other.currency && 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 */ @@ -119832,15 +111211,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionCumulativeGroupedBulkPrice + class CumulativeGroupedBulk private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -119870,7 +111249,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -119956,11 +111335,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -120105,16 +111488,6 @@ private constructor( */ @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]. * @@ -120251,21 +111624,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionCumulativeGroupedBulkPrice]. + * [CumulativeGroupedBulk]. * * The following fields are required: * ```java * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionCumulativeGroupedBulkPrice]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -120273,7 +111645,7 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -120292,35 +111664,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionCumulativeGroupedBulkPrice: - NewSubscriptionCumulativeGroupedBulkPrice - ) = apply { - cadence = newSubscriptionCumulativeGroupedBulkPrice.cadence + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence cumulativeGroupedBulkConfig = - newSubscriptionCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - itemId = newSubscriptionCumulativeGroupedBulkPrice.itemId - modelType = newSubscriptionCumulativeGroupedBulkPrice.modelType - name = newSubscriptionCumulativeGroupedBulkPrice.name - billableMetricId = - newSubscriptionCumulativeGroupedBulkPrice.billableMetricId - billedInAdvance = newSubscriptionCumulativeGroupedBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionCumulativeGroupedBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionCumulativeGroupedBulkPrice.conversionRate - currency = newSubscriptionCumulativeGroupedBulkPrice.currency - externalPriceId = newSubscriptionCumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionCumulativeGroupedBulkPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionCumulativeGroupedBulkPrice.invoiceGroupingKey + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + currency = cumulativeGroupedBulk.currency + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionCumulativeGroupedBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionCumulativeGroupedBulkPrice.metadata - referenceId = newSubscriptionCumulativeGroupedBulkPrice.referenceId + cumulativeGroupedBulk.invoicingCycleConfiguration + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId additionalProperties = - newSubscriptionCumulativeGroupedBulkPrice.additionalProperties - .toMutableMap() + cumulativeGroupedBulk.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -120363,18 +111727,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -120695,7 +112060,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionCumulativeGroupedBulkPrice]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -120704,21 +112069,20 @@ private constructor( * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionCumulativeGroupedBulkPrice = - NewSubscriptionCumulativeGroupedBulkPrice( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("cadence", cadence), checkRequired( "cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -120737,7 +112101,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionCumulativeGroupedBulkPrice = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -120745,7 +112109,11 @@ private constructor( cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -120780,7 +112148,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -121068,135 +112438,6 @@ private constructor( "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * 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 { - CUMULATIVE_GROUPED_BULK, - /** - * 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) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -122035,7 +113276,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CumulativeGroupedBulk && 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 && currency == other.currency && 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 */ @@ -122045,15 +113286,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMaxGroupTieredPackagePrice + class MaxGroupTieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, private val maxGroupTieredPackageConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -122083,7 +113324,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -122169,11 +113410,15 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_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). + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -122318,16 +113563,6 @@ private constructor( fun _maxGroupTieredPackageConfig(): JsonField = maxGroupTieredPackageConfig - /** - * 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]. * @@ -122464,21 +113699,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMaxGroupTieredPackagePrice]. + * [MaxGroupTieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMaxGroupTieredPackagePrice]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -122486,7 +113720,7 @@ private constructor( private var maxGroupTieredPackageConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -122505,35 +113739,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionMaxGroupTieredPackagePrice: - NewSubscriptionMaxGroupTieredPackagePrice - ) = apply { - cadence = newSubscriptionMaxGroupTieredPackagePrice.cadence - itemId = newSubscriptionMaxGroupTieredPackagePrice.itemId + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId maxGroupTieredPackageConfig = - newSubscriptionMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newSubscriptionMaxGroupTieredPackagePrice.modelType - name = newSubscriptionMaxGroupTieredPackagePrice.name - billableMetricId = - newSubscriptionMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionMaxGroupTieredPackagePrice.conversionRate - currency = newSubscriptionMaxGroupTieredPackagePrice.currency - externalPriceId = newSubscriptionMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionMaxGroupTieredPackagePrice.invoiceGroupingKey + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + currency = maxGroupTieredPackage.currency + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionMaxGroupTieredPackagePrice.metadata - referenceId = newSubscriptionMaxGroupTieredPackagePrice.referenceId + maxGroupTieredPackage.invoicingCycleConfiguration + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId additionalProperties = - newSubscriptionMaxGroupTieredPackagePrice.additionalProperties - .toMutableMap() + maxGroupTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -122576,18 +113802,19 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -122908,7 +114135,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMaxGroupTieredPackagePrice]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -122917,21 +114144,20 @@ private constructor( * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMaxGroupTieredPackagePrice = - NewSubscriptionMaxGroupTieredPackagePrice( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired( "maxGroupTieredPackageConfig", maxGroupTieredPackageConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -122950,7 +114176,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMaxGroupTieredPackagePrice = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -122958,7 +114184,11 @@ private constructor( cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -122993,7 +114223,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -123281,135 +114513,6 @@ private constructor( "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * 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 { - MAX_GROUP_TIERED_PACKAGE, - /** - * 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) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -124248,7 +115351,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MaxGroupTieredPackage && 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 && currency == other.currency && 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 */ @@ -124258,16 +115361,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedWithMeteredMinimumPrice + class GroupedWithMeteredMinimum private constructor( private val cadence: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -124297,7 +115400,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -124385,11 +115488,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -124534,16 +115641,6 @@ private constructor( */ @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]. * @@ -124680,21 +115777,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedWithMeteredMinimumPrice]. + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedWithMeteredMinimumPrice]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -124702,7 +115798,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -124721,41 +115818,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithMeteredMinimumPrice: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithMeteredMinimumPrice.cadence - groupedWithMeteredMinimumConfig = - newSubscriptionGroupedWithMeteredMinimumPrice - .groupedWithMeteredMinimumConfig - itemId = newSubscriptionGroupedWithMeteredMinimumPrice.itemId - modelType = newSubscriptionGroupedWithMeteredMinimumPrice.modelType - name = newSubscriptionGroupedWithMeteredMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithMeteredMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithMeteredMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithMeteredMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithMeteredMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithMeteredMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithMeteredMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithMeteredMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + currency = groupedWithMeteredMinimum.currency + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -124802,18 +115888,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -125134,8 +116221,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionGroupedWithMeteredMinimumPrice]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -125144,21 +116230,20 @@ private constructor( * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedWithMeteredMinimumPrice = - NewSubscriptionGroupedWithMeteredMinimumPrice( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithMeteredMinimumConfig", groupedWithMeteredMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -125177,7 +116262,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedWithMeteredMinimumPrice = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -125185,7 +116270,11 @@ private constructor( cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -125220,7 +116309,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -125508,136 +116599,6 @@ private constructor( "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -126476,7 +117437,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimum && 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 && currency == other.currency && 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 */ @@ -126486,15 +117447,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMatrixWithDisplayNamePrice + class MatrixWithDisplayName private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixWithDisplayNameConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -126524,7 +117485,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -126610,11 +117571,15 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -126759,16 +117724,6 @@ private constructor( fun _matrixWithDisplayNameConfig(): JsonField = matrixWithDisplayNameConfig - /** - * 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]. * @@ -126905,21 +117860,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMatrixWithDisplayNamePrice]. + * [MatrixWithDisplayName]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMatrixWithDisplayNamePrice]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -126927,7 +117881,7 @@ private constructor( private var matrixWithDisplayNameConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -126946,35 +117900,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionMatrixWithDisplayNamePrice: - NewSubscriptionMatrixWithDisplayNamePrice - ) = apply { - cadence = newSubscriptionMatrixWithDisplayNamePrice.cadence - itemId = newSubscriptionMatrixWithDisplayNamePrice.itemId + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId matrixWithDisplayNameConfig = - newSubscriptionMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newSubscriptionMatrixWithDisplayNamePrice.modelType - name = newSubscriptionMatrixWithDisplayNamePrice.name - billableMetricId = - newSubscriptionMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newSubscriptionMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixWithDisplayNamePrice.conversionRate - currency = newSubscriptionMatrixWithDisplayNamePrice.currency - externalPriceId = newSubscriptionMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionMatrixWithDisplayNamePrice.invoiceGroupingKey + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + currency = matrixWithDisplayName.currency + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixWithDisplayNamePrice.metadata - referenceId = newSubscriptionMatrixWithDisplayNamePrice.referenceId + matrixWithDisplayName.invoicingCycleConfiguration + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId additionalProperties = - newSubscriptionMatrixWithDisplayNamePrice.additionalProperties - .toMutableMap() + matrixWithDisplayName.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -127017,18 +117963,19 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -127349,7 +118296,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMatrixWithDisplayNamePrice]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -127358,21 +118305,20 @@ private constructor( * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMatrixWithDisplayNamePrice = - NewSubscriptionMatrixWithDisplayNamePrice( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired( "matrixWithDisplayNameConfig", matrixWithDisplayNameConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -127391,7 +118337,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMatrixWithDisplayNamePrice = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -127399,7 +118345,11 @@ private constructor( cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -127434,7 +118384,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -127722,135 +118674,6 @@ private constructor( "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * 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 { - MATRIX_WITH_DISPLAY_NAME, - /** - * 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) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -128689,7 +119512,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayName && 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 && currency == other.currency && 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 */ @@ -128699,15 +119522,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedTieredPackagePrice + class GroupedTieredPackage private constructor( private val cadence: JsonField, private val groupedTieredPackageConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -128737,7 +119560,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -128823,11 +119646,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -128972,16 +119799,6 @@ private constructor( */ @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]. * @@ -129118,28 +119935,27 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedTieredPackagePrice]. + * [GroupedTieredPackage]. * * The following fields are required: * ```java * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedTieredPackagePrice]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedTieredPackageConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -129158,34 +119974,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedTieredPackagePrice: - NewSubscriptionGroupedTieredPackagePrice - ) = apply { - cadence = newSubscriptionGroupedTieredPackagePrice.cadence - groupedTieredPackageConfig = - newSubscriptionGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newSubscriptionGroupedTieredPackagePrice.itemId - modelType = newSubscriptionGroupedTieredPackagePrice.modelType - name = newSubscriptionGroupedTieredPackagePrice.name - billableMetricId = newSubscriptionGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionGroupedTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedTieredPackagePrice.conversionRate - currency = newSubscriptionGroupedTieredPackagePrice.currency - externalPriceId = newSubscriptionGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedTieredPackagePrice.invoiceGroupingKey + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + currency = groupedTieredPackage.currency + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedTieredPackagePrice.metadata - referenceId = newSubscriptionGroupedTieredPackagePrice.referenceId + groupedTieredPackage.invoicingCycleConfiguration + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId additionalProperties = - newSubscriptionGroupedTieredPackagePrice.additionalProperties - .toMutableMap() + groupedTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -129228,18 +120036,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -129560,7 +120369,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionGroupedTieredPackagePrice]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -129569,18 +120378,17 @@ private constructor( * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedTieredPackagePrice = - NewSubscriptionGroupedTieredPackagePrice( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("cadence", cadence), checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -129599,7 +120407,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedTieredPackagePrice = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -129607,7 +120415,11 @@ private constructor( cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -129642,7 +120454,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -129929,135 +120743,6 @@ private constructor( "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * 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 { - GROUPED_TIERED_PACKAGE, - /** - * 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) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -130896,7 +121581,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPackage && 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 && currency == other.currency && 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 */ @@ -130906,7 +121591,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, 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/SubscriptionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt index fc804d4c..70902a8f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt @@ -1056,17 +1056,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1710,41 +1710,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1893,66 +1880,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1965,34 +1942,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2017,25 +1986,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2046,21 +2009,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2068,27 +2029,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2097,21 +2051,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2137,44 +2085,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2190,26 +2123,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2223,7 +2152,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2258,11 +2187,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2318,16 +2253,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2391,13 +2316,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2408,11 +2331,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2421,21 +2344,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2449,17 +2367,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2594,14 +2514,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2611,10 +2530,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2628,13 +2547,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2660,149 +2585,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2812,13 +2609,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2832,7 +2629,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2867,11 +2664,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2927,16 +2730,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3000,13 +2793,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3017,11 +2808,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3030,21 +2821,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3058,17 +2844,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3203,14 +2991,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3220,10 +3007,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3237,13 +3024,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3269,149 +3062,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3421,13 +3086,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3441,7 +3106,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3476,11 +3141,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3537,16 +3208,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3611,12 +3272,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3627,11 +3287,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3640,23 +3300,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3670,17 +3324,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3815,14 +3471,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3832,10 +3487,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3849,13 +3504,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3881,149 +3542,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4033,13 +3566,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4054,7 +3587,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4093,11 +3626,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4163,19 +3702,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4243,13 +3772,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4261,11 +3788,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4275,22 +3802,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4303,17 +3825,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4460,14 +3984,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4478,10 +4001,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4496,13 +4019,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4529,7 +4058,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4537,142 +4066,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4682,13 +4081,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4702,7 +4101,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4737,11 +4136,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4797,16 +4202,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4870,13 +4265,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4887,11 +4280,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4900,21 +4293,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4927,17 +4315,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5072,14 +4462,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5089,10 +4478,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5106,13 +4495,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5138,149 +4533,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5290,7 +4555,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5583,17 +4848,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5601,11 +4866,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5626,15 +4891,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5660,12 +4925,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5692,14 +4956,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5708,11 +4970,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5738,17 +5000,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5775,12 +5037,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5799,7 +5061,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5846,11 +5108,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5899,16 +5167,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5943,15 +5201,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5959,29 +5215,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6056,17 +5310,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6122,7 +5378,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6131,15 +5387,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6147,7 +5402,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6156,7 +5411,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6164,7 +5419,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6189,143 +5448,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6335,14 +5467,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6359,7 +5491,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6400,11 +5532,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6452,16 +5590,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6506,14 +5634,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6522,31 +5648,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6606,17 +5728,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6689,7 +5813,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6697,7 +5821,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6705,15 +5828,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6723,14 +5846,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6755,144 +5882,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6902,14 +5902,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6926,7 +5926,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6967,11 +5967,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7020,16 +6026,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7074,14 +6070,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7090,28 +6084,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7171,17 +6164,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7255,7 +6250,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7263,7 +6258,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7271,15 +6265,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7289,14 +6283,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7321,144 +6319,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7468,7 +6339,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9268,142 +8139,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 2569032e..edd314d2 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 @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException @@ -29,7 +28,7 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionFetchCostsParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val currency: String?, private val timeframeEnd: OffsetDateTime?, private val timeframeStart: OffsetDateTime?, @@ -38,7 +37,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** The currency or custom pricing unit to use. */ fun currency(): Optional = Optional.ofNullable(currency) @@ -64,13 +63,10 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionFetchCostsParams = builder().build() + /** * Returns a mutable builder for constructing an instance of [SubscriptionFetchCostsParams]. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -97,7 +93,11 @@ private constructor( additionalQueryParams = subscriptionFetchCostsParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** The currency or custom pricing unit to use. */ fun currency(currency: String?) = apply { this.currency = currency } @@ -233,17 +233,10 @@ private constructor( * Returns an immutable instance of [SubscriptionFetchCostsParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionFetchCostsParams = SubscriptionFetchCostsParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, currency, timeframeEnd, timeframeStart, @@ -255,7 +248,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } 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 edb2779c..2a47bb51 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 @@ -655,156 +655,154 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = - price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with * `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with * `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with * `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** * Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** * Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** * Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with * `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice - ) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** The price the cost is associated with */ 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 ac66b2f8..f107bdd6 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 @@ -3,10 +3,11 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint is used to fetch a [Subscription](/core-concepts##subscription) given an @@ -14,12 +15,12 @@ import java.util.Objects */ class SubscriptionFetchParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) fun _additionalHeaders(): Headers = additionalHeaders @@ -29,14 +30,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [SubscriptionFetchParams]. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - */ + @JvmStatic fun none(): SubscriptionFetchParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SubscriptionFetchParams]. */ @JvmStatic fun builder() = Builder() } @@ -54,7 +50,11 @@ private constructor( additionalQueryParams = subscriptionFetchParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -158,17 +158,10 @@ private constructor( * Returns an immutable instance of [SubscriptionFetchParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionFetchParams = SubscriptionFetchParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -176,7 +169,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } 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 2e815413..c8263072 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.SubscriptionService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [SubscriptionService.fetchSchedule] */ @@ -16,7 +16,7 @@ private constructor( private val service: SubscriptionService, private val params: SubscriptionFetchScheduleParams, private val response: SubscriptionFetchSchedulePageResponse, -) { +) : Page { /** * Delegates to [SubscriptionFetchSchedulePageResponse], but gracefully handles missing data. @@ -34,31 +34,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): SubscriptionFetchScheduleParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = - getNextPageParams().map { service.fetchSchedule(it) } + override fun nextPage(): SubscriptionFetchSchedulePage = service.fetchSchedule(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): SubscriptionFetchScheduleParams = params @@ -130,26 +121,6 @@ private constructor( ) } - class AutoPager(private val firstPage: SubscriptionFetchSchedulePage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 b9895452..524dd761 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.SubscriptionServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [SubscriptionServiceAsync.fetchSchedule] */ class SubscriptionFetchSchedulePageAsync private constructor( private val service: SubscriptionServiceAsync, + private val streamHandlerExecutor: Executor, private val params: SubscriptionFetchScheduleParams, private val response: SubscriptionFetchSchedulePageResponse, -) { +) : PageAsync { /** * Delegates to [SubscriptionFetchSchedulePageResponse], but gracefully handles missing data. @@ -35,33 +37,24 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): SubscriptionFetchScheduleParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.fetchSchedule(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.fetchSchedule(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = + AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): SubscriptionFetchScheduleParams = params @@ -80,6 +73,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -91,6 +85,7 @@ private constructor( class Builder internal constructor() { private var service: SubscriptionServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: SubscriptionFetchScheduleParams? = null private var response: SubscriptionFetchSchedulePageResponse? = null @@ -98,12 +93,17 @@ private constructor( internal fun from(subscriptionFetchSchedulePageAsync: SubscriptionFetchSchedulePageAsync) = apply { service = subscriptionFetchSchedulePageAsync.service + streamHandlerExecutor = subscriptionFetchSchedulePageAsync.streamHandlerExecutor params = subscriptionFetchSchedulePageAsync.params response = subscriptionFetchSchedulePageAsync.response } fun service(service: SubscriptionServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: SubscriptionFetchScheduleParams) = apply { this.params = params } @@ -120,6 +120,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -129,50 +130,22 @@ private constructor( fun build(): SubscriptionFetchSchedulePageAsync = SubscriptionFetchSchedulePageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: SubscriptionFetchSchedulePageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (SubscriptionFetchScheduleResponse) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionFetchSchedulePageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is SubscriptionFetchSchedulePageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "SubscriptionFetchSchedulePageAsync{service=$service, params=$params, response=$response}" + "SubscriptionFetchSchedulePageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 227b32c0..159f4d53 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 @@ -3,7 +3,6 @@ package com.withorb.api.models import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.time.OffsetDateTime @@ -19,7 +18,7 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionFetchScheduleParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val cursor: String?, private val limit: Long?, private val startDateGt: OffsetDateTime?, @@ -30,7 +29,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the @@ -57,14 +56,11 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionFetchScheduleParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [SubscriptionFetchScheduleParams]. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -97,7 +93,11 @@ private constructor( subscriptionFetchScheduleParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Cursor for pagination. This can be populated by the `next_cursor` value returned from the @@ -247,17 +247,10 @@ private constructor( * Returns an immutable instance of [SubscriptionFetchScheduleParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionFetchScheduleParams = SubscriptionFetchScheduleParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, cursor, limit, startDateGt, @@ -271,7 +264,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } 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 89a711c3..531312c3 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 @@ -6,7 +6,6 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.withorb.api.core.Enum import com.withorb.api.core.JsonField import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException @@ -194,7 +193,7 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionFetchUsageParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val billableMetricId: String?, private val firstDimensionKey: String?, private val firstDimensionValue: String?, @@ -209,7 +208,7 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * When specified in conjunction with `group_by`, this parameter filters usage to a single @@ -253,13 +252,10 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionFetchUsageParams = builder().build() + /** * Returns a mutable builder for constructing an instance of [SubscriptionFetchUsageParams]. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -298,7 +294,11 @@ private constructor( additionalQueryParams = subscriptionFetchUsageParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * When specified in conjunction with `group_by`, this parameter filters usage to a single @@ -492,17 +492,10 @@ private constructor( * Returns an immutable instance of [SubscriptionFetchUsageParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionFetchUsageParams = SubscriptionFetchUsageParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, billableMetricId, firstDimensionKey, firstDimensionValue, @@ -520,7 +513,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } 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 6dbe30e2..bcef627c 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 @@ -2,12 +2,12 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPager +import com.withorb.api.core.Page import com.withorb.api.core.checkRequired import com.withorb.api.services.blocking.SubscriptionService import java.util.Objects import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull /** @see [SubscriptionService.list] */ @@ -16,7 +16,7 @@ private constructor( private val service: SubscriptionService, private val params: SubscriptionListParams, private val response: Subscriptions, -) { +) : Page { /** * Delegates to [Subscriptions], but gracefully handles missing data. @@ -33,30 +33,22 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): SubscriptionListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } + override fun nextPage(): SubscriptionListPage = service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): SubscriptionListParams = params @@ -125,25 +117,6 @@ private constructor( ) } - class AutoPager(private val firstPage: SubscriptionListPage) : Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.data().size) { - yield(page.data()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true 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 45595107..394c5cb7 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 @@ -2,22 +2,24 @@ package com.withorb.api.models +import com.withorb.api.core.AutoPagerAsync +import com.withorb.api.core.PageAsync import com.withorb.api.core.checkRequired import com.withorb.api.services.async.SubscriptionServiceAsync import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor -import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull /** @see [SubscriptionServiceAsync.list] */ class SubscriptionListPageAsync private constructor( private val service: SubscriptionServiceAsync, + private val streamHandlerExecutor: Executor, private val params: SubscriptionListParams, private val response: Subscriptions, -) { +) : PageAsync { /** * Delegates to [Subscriptions], but gracefully handles missing data. @@ -34,33 +36,23 @@ private constructor( fun paginationMetadata(): Optional = response._paginationMetadata().getOptional("pagination_metadata") - fun hasNextPage(): Boolean = - data().isNotEmpty() && - paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent + override fun items(): List = data() - fun getNextPageParams(): Optional { - if (!hasNextPage()) { - return Optional.empty() - } + override fun hasNextPage(): Boolean = + items().isNotEmpty() && + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.isPresent - return Optional.of( - params - .toBuilder() - .apply { - paginationMetadata() - .flatMap { it._nextCursor().getOptional("next_cursor") } - .ifPresent { cursor(it) } - } - .build() - ) + fun nextPageParams(): SubscriptionListParams { + val nextCursor = + paginationMetadata().flatMap { it._nextCursor().getOptional("next_cursor") }.getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().cursor(nextCursor).build() } - fun getNextPage(): CompletableFuture> = - getNextPageParams() - .map { service.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + override fun nextPage(): CompletableFuture = + service.list(nextPageParams()) - fun autoPager(): AutoPager = AutoPager(this) + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): SubscriptionListParams = params @@ -78,6 +70,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -89,18 +82,24 @@ private constructor( class Builder internal constructor() { private var service: SubscriptionServiceAsync? = null + private var streamHandlerExecutor: Executor? = null private var params: SubscriptionListParams? = null private var response: Subscriptions? = null @JvmSynthetic internal fun from(subscriptionListPageAsync: SubscriptionListPageAsync) = apply { service = subscriptionListPageAsync.service + streamHandlerExecutor = subscriptionListPageAsync.streamHandlerExecutor params = subscriptionListPageAsync.params response = subscriptionListPageAsync.response } fun service(service: SubscriptionServiceAsync) = apply { this.service = service } + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + /** The parameters that were used to request this page. */ fun params(params: SubscriptionListParams) = apply { this.params = params } @@ -115,6 +114,7 @@ private constructor( * The following fields are required: * ```java * .service() + * .streamHandlerExecutor() * .params() * .response() * ``` @@ -124,47 +124,22 @@ private constructor( fun build(): SubscriptionListPageAsync = SubscriptionListPageAsync( checkRequired("service", service), + checkRequired("streamHandlerExecutor", streamHandlerExecutor), checkRequired("params", params), checkRequired("response", response), ) } - class AutoPager(private val firstPage: SubscriptionListPageAsync) { - - fun forEach(action: Predicate, executor: Executor): CompletableFuture { - fun CompletableFuture>.forEach( - action: (Subscription) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.data().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is SubscriptionListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + return /* spotless:off */ other is SubscriptionListPageAsync && service == other.service && streamHandlerExecutor == other.streamHandlerExecutor && params == other.params && response == other.response /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, streamHandlerExecutor, params, response) /* spotless:on */ override fun toString() = - "SubscriptionListPageAsync{service=$service, params=$params, response=$response}" + "SubscriptionListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" } 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 923ad5f9..6249c83d 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 @@ -33,6 +33,7 @@ import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.Unit as KUnit import kotlin.jvm.optionals.getOrNull /** @@ -102,13 +103,13 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionPriceIntervalsParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * A list of price intervals to add to the subscription. @@ -198,14 +199,11 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionPriceIntervalsParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [SubscriptionPriceIntervalsParams]. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -228,7 +226,11 @@ private constructor( subscriptionPriceIntervalsParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Sets the entire request body. @@ -486,17 +488,10 @@ private constructor( * Returns an immutable instance of [SubscriptionPriceIntervalsParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -507,7 +502,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } @@ -1319,96 +1314,50 @@ private constructor( } } - /** - * Alias for calling [addDiscount] with - * `Discount.ofAmountDiscountCreationParams(amountDiscountCreationParams)`. - */ - fun addDiscount(amountDiscountCreationParams: Discount.AmountDiscountCreationParams) = - addDiscount(Discount.ofAmountDiscountCreationParams(amountDiscountCreationParams)) + /** Alias for calling [addDiscount] with `Discount.ofAmount(amount)`. */ + fun addDiscount(amount: Discount.Amount) = addDiscount(Discount.ofAmount(amount)) /** * Alias for calling [addDiscount] with the following: * ```java - * Discount.AmountDiscountCreationParams.builder() - * .discountType(SubscriptionPriceIntervalsParams.Add.Discount.AmountDiscountCreationParams.DiscountType.AMOUNT) + * Discount.Amount.builder() * .amountDiscount(amountDiscount) * .build() * ``` */ - fun addAmountDiscountCreationParamsDiscount(amountDiscount: Double) = - addDiscount( - Discount.AmountDiscountCreationParams.builder() - .discountType( - SubscriptionPriceIntervalsParams.Add.Discount - .AmountDiscountCreationParams - .DiscountType - .AMOUNT - ) - .amountDiscount(amountDiscount) - .build() - ) + fun addAmountDiscount(amountDiscount: Double) = + addDiscount(Discount.Amount.builder().amountDiscount(amountDiscount).build()) - /** - * Alias for calling [addDiscount] with - * `Discount.ofPercentageDiscountCreationParams(percentageDiscountCreationParams)`. - */ - fun addDiscount( - percentageDiscountCreationParams: Discount.PercentageDiscountCreationParams - ) = - addDiscount( - Discount.ofPercentageDiscountCreationParams(percentageDiscountCreationParams) - ) + /** Alias for calling [addDiscount] with `Discount.ofPercentage(percentage)`. */ + fun addDiscount(percentage: Discount.Percentage) = + addDiscount(Discount.ofPercentage(percentage)) /** * Alias for calling [addDiscount] with the following: * ```java - * Discount.PercentageDiscountCreationParams.builder() - * .discountType(SubscriptionPriceIntervalsParams.Add.Discount.PercentageDiscountCreationParams.DiscountType.PERCENTAGE) + * Discount.Percentage.builder() * .percentageDiscount(percentageDiscount) * .build() * ``` */ - fun addPercentageDiscountCreationParamsDiscount(percentageDiscount: Double) = + fun addPercentageDiscount(percentageDiscount: Double) = addDiscount( - Discount.PercentageDiscountCreationParams.builder() - .discountType( - SubscriptionPriceIntervalsParams.Add.Discount - .PercentageDiscountCreationParams - .DiscountType - .PERCENTAGE - ) - .percentageDiscount(percentageDiscount) - .build() + Discount.Percentage.builder().percentageDiscount(percentageDiscount).build() ) - /** - * Alias for calling [addDiscount] with - * `Discount.ofUsageDiscountCreationParams(usageDiscountCreationParams)`. - */ - fun addDiscount(usageDiscountCreationParams: Discount.UsageDiscountCreationParams) = - addDiscount(Discount.ofUsageDiscountCreationParams(usageDiscountCreationParams)) + /** Alias for calling [addDiscount] with `Discount.ofUsage(usage)`. */ + fun addDiscount(usage: Discount.Usage) = addDiscount(Discount.ofUsage(usage)) /** * Alias for calling [addDiscount] with the following: * ```java - * Discount.UsageDiscountCreationParams.builder() - * .discountType(SubscriptionPriceIntervalsParams.Add.Discount.UsageDiscountCreationParams.DiscountType.USAGE) + * Discount.Usage.builder() * .usageDiscount(usageDiscount) * .build() * ``` */ - fun addUsageDiscountCreationParamsDiscount(usageDiscount: Double) = - addDiscount( - Discount.UsageDiscountCreationParams.builder() - .discountType( - SubscriptionPriceIntervalsParams.Add.Discount - .UsageDiscountCreationParams - .DiscountType - .USAGE - ) - .usageDiscount(usageDiscount) - .build() - ) + fun addUsageDiscount(usageDiscount: Double) = + addDiscount(Discount.Usage.builder().usageDiscount(usageDiscount).build()) /** * The end date of the price interval. This is the date that the price will stop billing @@ -1591,215 +1540,144 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } - /** Alias for calling [price] with `Price.ofNewFloatingUnit(newFloatingUnit)`. */ - fun price(newFloatingUnit: Price.NewFloatingUnitPrice) = - price(Price.ofNewFloatingUnit(newFloatingUnit)) + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofNewFloatingPackage(newFloatingPackage)`. */ - fun price(newFloatingPackage: Price.NewFloatingPackagePrice) = - price(Price.ofNewFloatingPackage(newFloatingPackage)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - /** Alias for calling [price] with `Price.ofNewFloatingMatrix(newFloatingMatrix)`. */ - fun price(newFloatingMatrix: Price.NewFloatingMatrixPrice) = - price(Price.ofNewFloatingMatrix(newFloatingMatrix)) + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** - * Alias for calling [price] with - * `Price.ofNewFloatingMatrixWithAllocation(newFloatingMatrixWithAllocation)`. + * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(newFloatingMatrixWithAllocation: Price.NewFloatingMatrixWithAllocationPrice) = - price(Price.ofNewFloatingMatrixWithAllocation(newFloatingMatrixWithAllocation)) + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = + price(Price.ofMatrixWithAllocation(matrixWithAllocation)) - /** Alias for calling [price] with `Price.ofNewFloatingTiered(newFloatingTiered)`. */ - fun price(newFloatingTiered: Price.NewFloatingTieredPrice) = - price(Price.ofNewFloatingTiered(newFloatingTiered)) + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** - * Alias for calling [price] with `Price.ofNewFloatingTieredBps(newFloatingTieredBps)`. - */ - fun price(newFloatingTieredBps: Price.NewFloatingTieredBpsPrice) = - price(Price.ofNewFloatingTieredBps(newFloatingTieredBps)) + /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - /** Alias for calling [price] with `Price.ofNewFloatingBps(newFloatingBps)`. */ - fun price(newFloatingBps: Price.NewFloatingBpsPrice) = - price(Price.ofNewFloatingBps(newFloatingBps)) + /** Alias for calling [price] with `Price.ofBps(bps)`. */ + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - /** Alias for calling [price] with `Price.ofNewFloatingBulkBps(newFloatingBulkBps)`. */ - fun price(newFloatingBulkBps: Price.NewFloatingBulkBpsPrice) = - price(Price.ofNewFloatingBulkBps(newFloatingBulkBps)) + /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** Alias for calling [price] with `Price.ofNewFloatingBulk(newFloatingBulk)`. */ - fun price(newFloatingBulk: Price.NewFloatingBulkPrice) = - price(Price.ofNewFloatingBulk(newFloatingBulk)) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** - * Alias for calling [price] with - * `Price.ofNewFloatingThresholdTotalAmount(newFloatingThresholdTotalAmount)`. + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(newFloatingThresholdTotalAmount: Price.NewFloatingThresholdTotalAmountPrice) = - price(Price.ofNewFloatingThresholdTotalAmount(newFloatingThresholdTotalAmount)) + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - /** - * Alias for calling [price] with - * `Price.ofNewFloatingTieredPackage(newFloatingTieredPackage)`. - */ - fun price(newFloatingTieredPackage: Price.NewFloatingTieredPackagePrice) = - price(Price.ofNewFloatingTieredPackage(newFloatingTieredPackage)) + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: Price.TieredPackage) = + price(Price.ofTieredPackage(tieredPackage)) - /** - * Alias for calling [price] with - * `Price.ofNewFloatingGroupedTiered(newFloatingGroupedTiered)`. - */ - fun price(newFloatingGroupedTiered: Price.NewFloatingGroupedTieredPrice) = - price(Price.ofNewFloatingGroupedTiered(newFloatingGroupedTiered)) + /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ + fun price(groupedTiered: Price.GroupedTiered) = + price(Price.ofGroupedTiered(groupedTiered)) /** * Alias for calling [price] with - * `Price.ofNewFloatingMaxGroupTieredPackage(newFloatingMaxGroupTieredPackage)`. + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price( - newFloatingMaxGroupTieredPackage: Price.NewFloatingMaxGroupTieredPackagePrice - ) = price(Price.ofNewFloatingMaxGroupTieredPackage(newFloatingMaxGroupTieredPackage)) + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) - /** - * Alias for calling [price] with - * `Price.ofNewFloatingTieredWithMinimum(newFloatingTieredWithMinimum)`. - */ - fun price(newFloatingTieredWithMinimum: Price.NewFloatingTieredWithMinimumPrice) = - price(Price.ofNewFloatingTieredWithMinimum(newFloatingTieredWithMinimum)) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: Price.TieredWithMinimum) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with - * `Price.ofNewFloatingPackageWithAllocation(newFloatingPackageWithAllocation)`. + * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price( - newFloatingPackageWithAllocation: Price.NewFloatingPackageWithAllocationPrice - ) = price(Price.ofNewFloatingPackageWithAllocation(newFloatingPackageWithAllocation)) + fun price(packageWithAllocation: Price.PackageWithAllocation) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) /** * Alias for calling [price] with - * `Price.ofNewFloatingTieredPackageWithMinimum(newFloatingTieredPackageWithMinimum)`. + * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price( - newFloatingTieredPackageWithMinimum: Price.NewFloatingTieredPackageWithMinimumPrice - ) = - price( - Price.ofNewFloatingTieredPackageWithMinimum(newFloatingTieredPackageWithMinimum) - ) + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = + price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) - /** - * Alias for calling [price] with - * `Price.ofNewFloatingUnitWithPercent(newFloatingUnitWithPercent)`. - */ - fun price(newFloatingUnitWithPercent: Price.NewFloatingUnitWithPercentPrice) = - price(Price.ofNewFloatingUnitWithPercent(newFloatingUnitWithPercent)) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: Price.UnitWithPercent) = + price(Price.ofUnitWithPercent(unitWithPercent)) /** - * Alias for calling [price] with - * `Price.ofNewFloatingTieredWithProration(newFloatingTieredWithProration)`. + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(newFloatingTieredWithProration: Price.NewFloatingTieredWithProrationPrice) = - price(Price.ofNewFloatingTieredWithProration(newFloatingTieredWithProration)) + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewFloatingUnitWithProration(newFloatingUnitWithProration)`. - */ - fun price(newFloatingUnitWithProration: Price.NewFloatingUnitWithProrationPrice) = - price(Price.ofNewFloatingUnitWithProration(newFloatingUnitWithProration)) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: Price.UnitWithProration) = + price(Price.ofUnitWithProration(unitWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewFloatingGroupedAllocation(newFloatingGroupedAllocation)`. - */ - fun price(newFloatingGroupedAllocation: Price.NewFloatingGroupedAllocationPrice) = - price(Price.ofNewFloatingGroupedAllocation(newFloatingGroupedAllocation)) + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: Price.GroupedAllocation) = + price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with - * `Price.ofNewFloatingGroupedWithProratedMinimum(newFloatingGroupedWithProratedMinimum)`. + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price( - newFloatingGroupedWithProratedMinimum: - Price.NewFloatingGroupedWithProratedMinimumPrice - ) = - price( - Price.ofNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum - ) - ) + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with - * `Price.ofNewFloatingGroupedWithMeteredMinimum(newFloatingGroupedWithMeteredMinimum)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price( - newFloatingGroupedWithMeteredMinimum: - Price.NewFloatingGroupedWithMeteredMinimumPrice - ) = - price( - Price.ofNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum - ) - ) + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with - * `Price.ofNewFloatingMatrixWithDisplayName(newFloatingMatrixWithDisplayName)`. + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price( - newFloatingMatrixWithDisplayName: Price.NewFloatingMatrixWithDisplayNamePrice - ) = price(Price.ofNewFloatingMatrixWithDisplayName(newFloatingMatrixWithDisplayName)) + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) - /** - * Alias for calling [price] with - * `Price.ofNewFloatingBulkWithProration(newFloatingBulkWithProration)`. - */ - fun price(newFloatingBulkWithProration: Price.NewFloatingBulkWithProrationPrice) = - price(Price.ofNewFloatingBulkWithProration(newFloatingBulkWithProration)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) /** - * Alias for calling [price] with - * `Price.ofNewFloatingGroupedTieredPackage(newFloatingGroupedTieredPackage)`. + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(newFloatingGroupedTieredPackage: Price.NewFloatingGroupedTieredPackagePrice) = - price(Price.ofNewFloatingGroupedTieredPackage(newFloatingGroupedTieredPackage)) + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with - * `Price.ofNewFloatingScalableMatrixWithUnitPricing(newFloatingScalableMatrixWithUnitPricing)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price( - newFloatingScalableMatrixWithUnitPricing: - Price.NewFloatingScalableMatrixWithUnitPricingPrice - ) = - price( - Price.ofNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing - ) - ) + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with - * `Price.ofNewFloatingScalableMatrixWithTieredPricing(newFloatingScalableMatrixWithTieredPricing)`. + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - newFloatingScalableMatrixWithTieredPricing: - Price.NewFloatingScalableMatrixWithTieredPricingPrice - ) = - price( - Price.ofNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing - ) - ) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with - * `Price.ofNewFloatingCumulativeGroupedBulk(newFloatingCumulativeGroupedBulk)`. + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price( - newFloatingCumulativeGroupedBulk: Price.NewFloatingCumulativeGroupedBulkPrice - ) = price(Price.ofNewFloatingCumulativeGroupedBulk(newFloatingCumulativeGroupedBulk)) + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -2002,7 +1880,7 @@ private constructor( } accept( - object : Visitor { + object : Visitor { override fun visitDateTime(dateTime: OffsetDateTime) {} override fun visitBillingCycleRelative( @@ -2605,49 +2483,37 @@ private constructor( @JsonSerialize(using = Discount.Serializer::class) class Discount private constructor( - private val amountDiscountCreationParams: AmountDiscountCreationParams? = null, - private val percentageDiscountCreationParams: PercentageDiscountCreationParams? = null, - private val usageDiscountCreationParams: UsageDiscountCreationParams? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amountDiscountCreationParams(): Optional = - Optional.ofNullable(amountDiscountCreationParams) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentageDiscountCreationParams(): Optional = - Optional.ofNullable(percentageDiscountCreationParams) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usageDiscountCreationParams(): Optional = - Optional.ofNullable(usageDiscountCreationParams) + fun usage(): Optional = Optional.ofNullable(usage) - fun isAmountDiscountCreationParams(): Boolean = amountDiscountCreationParams != null + fun isAmount(): Boolean = amount != null - fun isPercentageDiscountCreationParams(): Boolean = - percentageDiscountCreationParams != null + fun isPercentage(): Boolean = percentage != null - fun isUsageDiscountCreationParams(): Boolean = usageDiscountCreationParams != null + fun isUsage(): Boolean = usage != null - fun asAmountDiscountCreationParams(): AmountDiscountCreationParams = - amountDiscountCreationParams.getOrThrow("amountDiscountCreationParams") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentageDiscountCreationParams(): PercentageDiscountCreationParams = - percentageDiscountCreationParams.getOrThrow("percentageDiscountCreationParams") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsageDiscountCreationParams(): UsageDiscountCreationParams = - usageDiscountCreationParams.getOrThrow("usageDiscountCreationParams") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - amountDiscountCreationParams != null -> - visitor.visitAmountDiscountCreationParams(amountDiscountCreationParams) - percentageDiscountCreationParams != null -> - visitor.visitPercentageDiscountCreationParams( - percentageDiscountCreationParams - ) - usageDiscountCreationParams != null -> - visitor.visitUsageDiscountCreationParams(usageDiscountCreationParams) + amount != null -> visitor.visitAmount(amount) + percentage != null -> visitor.visitPercentage(percentage) + usage != null -> visitor.visitUsage(usage) else -> visitor.unknown(_json) } @@ -2659,23 +2525,17 @@ private constructor( } accept( - object : Visitor { - override fun visitAmountDiscountCreationParams( - amountDiscountCreationParams: AmountDiscountCreationParams - ) { - amountDiscountCreationParams.validate() + object : Visitor { + override fun visitAmount(amount: Amount) { + amount.validate() } - override fun visitPercentageDiscountCreationParams( - percentageDiscountCreationParams: PercentageDiscountCreationParams - ) { - percentageDiscountCreationParams.validate() + override fun visitPercentage(percentage: Percentage) { + percentage.validate() } - override fun visitUsageDiscountCreationParams( - usageDiscountCreationParams: UsageDiscountCreationParams - ) { - usageDiscountCreationParams.validate() + override fun visitUsage(usage: Usage) { + usage.validate() } } ) @@ -2700,17 +2560,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmountDiscountCreationParams( - amountDiscountCreationParams: AmountDiscountCreationParams - ) = amountDiscountCreationParams.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentageDiscountCreationParams( - percentageDiscountCreationParams: PercentageDiscountCreationParams - ) = percentageDiscountCreationParams.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsageDiscountCreationParams( - usageDiscountCreationParams: UsageDiscountCreationParams - ) = usageDiscountCreationParams.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2721,39 +2575,28 @@ private constructor( return true } - return /* spotless:off */ other is Discount && amountDiscountCreationParams == other.amountDiscountCreationParams && percentageDiscountCreationParams == other.percentageDiscountCreationParams && usageDiscountCreationParams == other.usageDiscountCreationParams /* spotless:on */ + return /* spotless:off */ other is Discount && amount == other.amount && percentage == other.percentage && usage == other.usage /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(amountDiscountCreationParams, percentageDiscountCreationParams, usageDiscountCreationParams) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(amount, percentage, usage) /* spotless:on */ override fun toString(): String = when { - amountDiscountCreationParams != null -> - "Discount{amountDiscountCreationParams=$amountDiscountCreationParams}" - percentageDiscountCreationParams != null -> - "Discount{percentageDiscountCreationParams=$percentageDiscountCreationParams}" - usageDiscountCreationParams != null -> - "Discount{usageDiscountCreationParams=$usageDiscountCreationParams}" + amount != null -> "Discount{amount=$amount}" + percentage != null -> "Discount{percentage=$percentage}" + usage != null -> "Discount{usage=$usage}" _json != null -> "Discount{_unknown=$_json}" else -> throw IllegalStateException("Invalid Discount") } companion object { - @JvmStatic - fun ofAmountDiscountCreationParams( - amountDiscountCreationParams: AmountDiscountCreationParams - ) = Discount(amountDiscountCreationParams = amountDiscountCreationParams) + @JvmStatic fun ofAmount(amount: Amount) = Discount(amount = amount) @JvmStatic - fun ofPercentageDiscountCreationParams( - percentageDiscountCreationParams: PercentageDiscountCreationParams - ) = Discount(percentageDiscountCreationParams = percentageDiscountCreationParams) + fun ofPercentage(percentage: Percentage) = Discount(percentage = percentage) - @JvmStatic - fun ofUsageDiscountCreationParams( - usageDiscountCreationParams: UsageDiscountCreationParams - ) = Discount(usageDiscountCreationParams = usageDiscountCreationParams) + @JvmStatic fun ofUsage(usage: Usage) = Discount(usage = usage) } /** @@ -2762,17 +2605,11 @@ private constructor( */ interface Visitor { - fun visitAmountDiscountCreationParams( - amountDiscountCreationParams: AmountDiscountCreationParams - ): T + fun visitAmount(amount: Amount): T - fun visitPercentageDiscountCreationParams( - percentageDiscountCreationParams: PercentageDiscountCreationParams - ): T + fun visitPercentage(percentage: Percentage): T - fun visitUsageDiscountCreationParams( - usageDiscountCreationParams: UsageDiscountCreationParams - ): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [Discount] to a value of type [T]. @@ -2798,29 +2635,19 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Discount(amountDiscountCreationParams = it, _json = json) } - ?: Discount(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(amount = it, _json = json) + } ?: Discount(_json = json) } "percentage" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Discount(percentageDiscountCreationParams = it, _json = json) - } ?: Discount(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(percentage = it, _json = json) + } ?: Discount(_json = json) } "usage" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Discount(usageDiscountCreationParams = it, _json = json) } - ?: Discount(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Discount(usage = it, _json = json) + } ?: Discount(_json = json) } } @@ -2836,22 +2663,19 @@ private constructor( provider: SerializerProvider, ) { when { - value.amountDiscountCreationParams != null -> - generator.writeObject(value.amountDiscountCreationParams) - value.percentageDiscountCreationParams != null -> - generator.writeObject(value.percentageDiscountCreationParams) - value.usageDiscountCreationParams != null -> - generator.writeObject(value.usageDiscountCreationParams) + value.amount != null -> generator.writeObject(value.amount) + value.percentage != null -> generator.writeObject(value.percentage) + value.usage != null -> generator.writeObject(value.usage) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Discount") } } } - class AmountDiscountCreationParams + class Amount private constructor( private val amountDiscount: JsonField, - private val discountType: JsonField, + private val discountType: JsonValue, private val additionalProperties: MutableMap, ) { @@ -2862,7 +2686,7 @@ private constructor( amountDiscount: JsonField = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), ) : this(amountDiscount, discountType, mutableMapOf()) /** @@ -2875,11 +2699,17 @@ private constructor( fun amountDiscount(): Double = amountDiscount.getRequired("amount_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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * Returns the raw JSON value of [amountDiscount]. @@ -2891,16 +2721,6 @@ private constructor( @ExcludeMissing fun _amountDiscount(): JsonField = amountDiscount - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -2916,33 +2736,29 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountCreationParams]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() - * .discountType() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountCreationParams]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountCreationParams: AmountDiscountCreationParams) = - apply { - amountDiscount = amountDiscountCreationParams.amountDiscount - discountType = amountDiscountCreationParams.discountType - additionalProperties = - amountDiscountCreationParams.additionalProperties.toMutableMap() - } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + discountType = amount.discountType + additionalProperties = amount.additionalProperties.toMutableMap() + } /** Only available if discount_type is `amount`. */ fun amountDiscount(amountDiscount: Double) = @@ -2959,20 +2775,241 @@ private constructor( this.amountDiscount = amountDiscount } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) + /** + * 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("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun discountType(discountType: JsonValue) = apply { + this.discountType = discountType + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Returns an immutable instance of [Amount]. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amountDiscount() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun discountType(discountType: JsonField) = apply { + fun build(): Amount = + Amount( + checkRequired("amountDiscount", amountDiscount), + discountType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Amount = apply { + if (validated) { + return@apply + } + + amountDiscount() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' 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 (amountDiscount.asKnown().isPresent) 1 else 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && discountType == other.discountType && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amountDiscount, discountType, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Amount{amountDiscount=$amountDiscount, discountType=$discountType, additionalProperties=$additionalProperties}" + } + + class Percentage + private constructor( + private val discountType: JsonValue, + private val percentageDiscount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("discount_type") + @ExcludeMissing + discountType: JsonValue = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + percentageDiscount: JsonField = JsonMissing.of(), + ) : this(discountType, percentageDiscount, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). + */ + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType + + /** + * Only available if discount_type is `percentage`. This is a number between 0 + * and 1. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * Returns the raw JSON value of [percentageDiscount]. + * + * Unlike [percentageDiscount], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percentage_discount") + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Percentage]. + * + * The following fields are required: + * ```java + * .percentageDiscount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Percentage]. */ + class Builder internal constructor() { + + private var discountType: JsonValue = JsonValue.from("percentage") + private var percentageDiscount: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(percentage: Percentage) = apply { + discountType = percentage.discountType + percentageDiscount = percentage.percentageDiscount + additionalProperties = percentage.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } + /** + * Only available if discount_type is `percentage`. This is a number between 0 + * and 1. + */ + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** + * Sets [Builder.percentageDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.percentageDiscount] with a well-typed + * [Double] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2996,374 +3033,20 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountCreationParams]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .amountDiscount() - * .discountType() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AmountDiscountCreationParams = - AmountDiscountCreationParams( - checkRequired("amountDiscount", amountDiscount), - checkRequired("discountType", discountType), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AmountDiscountCreationParams = apply { - if (validated) { - return@apply - } - - amountDiscount() - discountType().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amountDiscount.asKnown().isPresent) 1 else 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) - - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AmountDiscountCreationParams && amountDiscount == other.amountDiscount && discountType == other.discountType && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amountDiscount, discountType, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AmountDiscountCreationParams{amountDiscount=$amountDiscount, discountType=$discountType, additionalProperties=$additionalProperties}" - } - - class PercentageDiscountCreationParams - private constructor( - private val discountType: JsonField, - private val percentageDiscount: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("discount_type") - @ExcludeMissing - discountType: JsonField = JsonMissing.of(), - @JsonProperty("percentage_discount") - @ExcludeMissing - percentageDiscount: JsonField = JsonMissing.of(), - ) : this(discountType, percentageDiscount, 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 discountType(): DiscountType = discountType.getRequired("discount_type") - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun percentageDiscount(): Double = - percentageDiscount.getRequired("percentage_discount") - - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - - /** - * Returns the raw JSON value of [percentageDiscount]. - * - * Unlike [percentageDiscount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("percentage_discount") - @ExcludeMissing - fun _percentageDiscount(): JsonField = percentageDiscount - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountCreationParams]. - * - * The following fields are required: - * ```java - * .discountType() - * .percentageDiscount() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PercentageDiscountCreationParams]. */ - class Builder internal constructor() { - - private var discountType: JsonField? = null - private var percentageDiscount: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - percentageDiscountCreationParams: PercentageDiscountCreationParams - ) = apply { - discountType = percentageDiscountCreationParams.discountType - percentageDiscount = percentageDiscountCreationParams.percentageDiscount - additionalProperties = - percentageDiscountCreationParams.additionalProperties.toMutableMap() - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - - /** - * Sets [Builder.discountType] to an arbitrary JSON value. - * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun discountType(discountType: JsonField) = apply { - this.discountType = discountType - } - - /** - * Only available if discount_type is `percentage`. This is a number between 0 - * and 1. - */ - fun percentageDiscount(percentageDiscount: Double) = - percentageDiscount(JsonField.of(percentageDiscount)) - - /** - * Sets [Builder.percentageDiscount] to an arbitrary JSON value. - * - * You should usually call [Builder.percentageDiscount] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun percentageDiscount(percentageDiscount: JsonField) = apply { - this.percentageDiscount = percentageDiscount - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PercentageDiscountCreationParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .discountType() * .percentageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountCreationParams = - PercentageDiscountCreationParams( - checkRequired("discountType", discountType), + fun build(): Percentage = + Percentage( + discountType, checkRequired("percentageDiscount", percentageDiscount), additionalProperties.toMutableMap(), ) @@ -3371,12 +3054,16 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountCreationParams = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } percentageDiscount() validated = true } @@ -3397,145 +3084,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (percentageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountCreationParams && discountType == other.discountType && percentageDiscount == other.percentageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && discountType == other.discountType && percentageDiscount == other.percentageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3545,12 +3102,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountCreationParams{discountType=$discountType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" + "Percentage{discountType=$discountType, percentageDiscount=$percentageDiscount, additionalProperties=$additionalProperties}" } - class UsageDiscountCreationParams + class Usage private constructor( - private val discountType: JsonField, + private val discountType: JsonValue, private val usageDiscount: JsonField, private val additionalProperties: MutableMap, ) { @@ -3559,18 +3116,24 @@ private constructor( private constructor( @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("usage_discount") @ExcludeMissing usageDiscount: JsonField = JsonMissing.of(), ) : this(discountType, usageDiscount, 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * Only available if discount_type is `usage`. Number of usage units that this @@ -3582,16 +3145,6 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [usageDiscount]. * @@ -3617,45 +3170,43 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountCreationParams]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java - * .discountType() * .usageDiscount() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountCreationParams]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountCreationParams: UsageDiscountCreationParams) = - apply { - discountType = usageDiscountCreationParams.discountType - usageDiscount = usageDiscountCreationParams.usageDiscount - additionalProperties = - usageDiscountCreationParams.additionalProperties.toMutableMap() - } - - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) + internal fun from(usage: Usage) = apply { + discountType = usage.discountType + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() + } /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed - * [DiscountType] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -3700,21 +3251,20 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountCreationParams]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .discountType() * .usageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountCreationParams = - UsageDiscountCreationParams( - checkRequired("discountType", discountType), + fun build(): Usage = + Usage( + discountType, checkRequired("usageDiscount", usageDiscount), additionalProperties.toMutableMap(), ) @@ -3722,12 +3272,16 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountCreationParams = apply { + fun validate(): Usage = apply { if (validated) { return@apply } - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } usageDiscount() validated = true } @@ -3748,145 +3302,15 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountCreationParams && discountType == other.discountType && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && discountType == other.discountType && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3896,7 +3320,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountCreationParams{discountType=$discountType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{discountType=$discountType, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -3945,7 +3369,7 @@ private constructor( } accept( - object : Visitor { + object : Visitor { override fun visitDateTime(dateTime: OffsetDateTime) {} override fun visitBillingCycleRelative( @@ -4305,392 +3729,287 @@ private constructor( @JsonSerialize(using = Price.Serializer::class) class Price private constructor( - private val newFloatingUnit: NewFloatingUnitPrice? = null, - private val newFloatingPackage: NewFloatingPackagePrice? = null, - private val newFloatingMatrix: NewFloatingMatrixPrice? = null, - private val newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice? = - null, - private val newFloatingTiered: NewFloatingTieredPrice? = null, - private val newFloatingTieredBps: NewFloatingTieredBpsPrice? = null, - private val newFloatingBps: NewFloatingBpsPrice? = null, - private val newFloatingBulkBps: NewFloatingBulkBpsPrice? = null, - private val newFloatingBulk: NewFloatingBulkPrice? = null, - private val newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice? = - null, - private val newFloatingTieredPackage: NewFloatingTieredPackagePrice? = null, - private val newFloatingGroupedTiered: NewFloatingGroupedTieredPrice? = null, - private val newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice? = - null, - private val newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice? = null, - private val newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice? = - null, - private val newFloatingTieredPackageWithMinimum: - NewFloatingTieredPackageWithMinimumPrice? = - null, - private val newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice? = null, - private val newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice? = null, - private val newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice? = null, - private val newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice? = null, - private val newFloatingGroupedWithProratedMinimum: - NewFloatingGroupedWithProratedMinimumPrice? = - null, - private val newFloatingGroupedWithMeteredMinimum: - NewFloatingGroupedWithMeteredMinimumPrice? = - null, - private val newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice? = - null, - private val newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice? = null, - private val newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice? = - null, - private val newFloatingScalableMatrixWithUnitPricing: - NewFloatingScalableMatrixWithUnitPricingPrice? = - null, - private val newFloatingScalableMatrixWithTieredPricing: - NewFloatingScalableMatrixWithTieredPricingPrice? = - null, - private val newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice? = - null, + private val unit: Unit? = null, + private val package_: Package? = null, + private val matrix: Matrix? = null, + private val matrixWithAllocation: MatrixWithAllocation? = null, + private val tiered: Tiered? = null, + private val tieredBps: TieredBps? = null, + private val bps: Bps? = null, + private val bulkBps: BulkBps? = null, + private val bulk: Bulk? = null, + private val thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val groupedTiered: GroupedTiered? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val tieredPackageWithMinimum: TieredPackageWithMinimum? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val bulkWithProration: BulkWithProration? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, private val _json: JsonValue? = null, ) { - fun newFloatingUnit(): Optional = - Optional.ofNullable(newFloatingUnit) + fun unit(): Optional = Optional.ofNullable(unit) - fun newFloatingPackage(): Optional = - Optional.ofNullable(newFloatingPackage) + fun package_(): Optional = Optional.ofNullable(package_) - fun newFloatingMatrix(): Optional = - Optional.ofNullable(newFloatingMatrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun newFloatingMatrixWithAllocation(): Optional = - Optional.ofNullable(newFloatingMatrixWithAllocation) + fun matrixWithAllocation(): Optional = + Optional.ofNullable(matrixWithAllocation) - fun newFloatingTiered(): Optional = - Optional.ofNullable(newFloatingTiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun newFloatingTieredBps(): Optional = - Optional.ofNullable(newFloatingTieredBps) + fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - fun newFloatingBps(): Optional = - Optional.ofNullable(newFloatingBps) + fun bps(): Optional = Optional.ofNullable(bps) - fun newFloatingBulkBps(): Optional = - Optional.ofNullable(newFloatingBulkBps) + fun bulkBps(): Optional = Optional.ofNullable(bulkBps) - fun newFloatingBulk(): Optional = - Optional.ofNullable(newFloatingBulk) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun newFloatingThresholdTotalAmount(): Optional = - Optional.ofNullable(newFloatingThresholdTotalAmount) + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) - fun newFloatingTieredPackage(): Optional = - Optional.ofNullable(newFloatingTieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun newFloatingGroupedTiered(): Optional = - Optional.ofNullable(newFloatingGroupedTiered) + fun groupedTiered(): Optional = Optional.ofNullable(groupedTiered) - fun newFloatingMaxGroupTieredPackage(): - Optional = - Optional.ofNullable(newFloatingMaxGroupTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) - fun newFloatingTieredWithMinimum(): Optional = - Optional.ofNullable(newFloatingTieredWithMinimum) + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) - fun newFloatingPackageWithAllocation(): - Optional = - Optional.ofNullable(newFloatingPackageWithAllocation) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) - fun newFloatingTieredPackageWithMinimum(): - Optional = - Optional.ofNullable(newFloatingTieredPackageWithMinimum) + fun tieredPackageWithMinimum(): Optional = + Optional.ofNullable(tieredPackageWithMinimum) - fun newFloatingUnitWithPercent(): Optional = - Optional.ofNullable(newFloatingUnitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun newFloatingTieredWithProration(): Optional = - Optional.ofNullable(newFloatingTieredWithProration) + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) - fun newFloatingUnitWithProration(): Optional = - Optional.ofNullable(newFloatingUnitWithProration) + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) - fun newFloatingGroupedAllocation(): Optional = - Optional.ofNullable(newFloatingGroupedAllocation) + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) - fun newFloatingGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newFloatingGroupedWithProratedMinimum) + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) - fun newFloatingGroupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(newFloatingGroupedWithMeteredMinimum) + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) - fun newFloatingMatrixWithDisplayName(): - Optional = - Optional.ofNullable(newFloatingMatrixWithDisplayName) + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) - fun newFloatingBulkWithProration(): Optional = - Optional.ofNullable(newFloatingBulkWithProration) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) - fun newFloatingGroupedTieredPackage(): Optional = - Optional.ofNullable(newFloatingGroupedTieredPackage) + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) - fun newFloatingScalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(newFloatingScalableMatrixWithUnitPricing) + fun scalableMatrixWithUnitPricing(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) - fun newFloatingScalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(newFloatingScalableMatrixWithTieredPricing) + fun scalableMatrixWithTieredPricing(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) - fun newFloatingCumulativeGroupedBulk(): - Optional = - Optional.ofNullable(newFloatingCumulativeGroupedBulk) + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) - fun isNewFloatingUnit(): Boolean = newFloatingUnit != null + fun isUnit(): Boolean = unit != null - fun isNewFloatingPackage(): Boolean = newFloatingPackage != null + fun isPackage(): Boolean = package_ != null - fun isNewFloatingMatrix(): Boolean = newFloatingMatrix != null + fun isMatrix(): Boolean = matrix != null - fun isNewFloatingMatrixWithAllocation(): Boolean = - newFloatingMatrixWithAllocation != null + fun isMatrixWithAllocation(): Boolean = matrixWithAllocation != null - fun isNewFloatingTiered(): Boolean = newFloatingTiered != null + fun isTiered(): Boolean = tiered != null - fun isNewFloatingTieredBps(): Boolean = newFloatingTieredBps != null + fun isTieredBps(): Boolean = tieredBps != null - fun isNewFloatingBps(): Boolean = newFloatingBps != null + fun isBps(): Boolean = bps != null - fun isNewFloatingBulkBps(): Boolean = newFloatingBulkBps != null + fun isBulkBps(): Boolean = bulkBps != null - fun isNewFloatingBulk(): Boolean = newFloatingBulk != null + fun isBulk(): Boolean = bulk != null - fun isNewFloatingThresholdTotalAmount(): Boolean = - newFloatingThresholdTotalAmount != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isNewFloatingTieredPackage(): Boolean = newFloatingTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null - fun isNewFloatingGroupedTiered(): Boolean = newFloatingGroupedTiered != null + fun isGroupedTiered(): Boolean = groupedTiered != null - fun isNewFloatingMaxGroupTieredPackage(): Boolean = - newFloatingMaxGroupTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isNewFloatingTieredWithMinimum(): Boolean = newFloatingTieredWithMinimum != null + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isNewFloatingPackageWithAllocation(): Boolean = - newFloatingPackageWithAllocation != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun isNewFloatingTieredPackageWithMinimum(): Boolean = - newFloatingTieredPackageWithMinimum != null + fun isTieredPackageWithMinimum(): Boolean = tieredPackageWithMinimum != null - fun isNewFloatingUnitWithPercent(): Boolean = newFloatingUnitWithPercent != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun isNewFloatingTieredWithProration(): Boolean = newFloatingTieredWithProration != null + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun isNewFloatingUnitWithProration(): Boolean = newFloatingUnitWithProration != null + fun isUnitWithProration(): Boolean = unitWithProration != null - fun isNewFloatingGroupedAllocation(): Boolean = newFloatingGroupedAllocation != null + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isNewFloatingGroupedWithProratedMinimum(): Boolean = - newFloatingGroupedWithProratedMinimum != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun isNewFloatingGroupedWithMeteredMinimum(): Boolean = - newFloatingGroupedWithMeteredMinimum != null + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isNewFloatingMatrixWithDisplayName(): Boolean = - newFloatingMatrixWithDisplayName != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isNewFloatingBulkWithProration(): Boolean = newFloatingBulkWithProration != null + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isNewFloatingGroupedTieredPackage(): Boolean = - newFloatingGroupedTieredPackage != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun isNewFloatingScalableMatrixWithUnitPricing(): Boolean = - newFloatingScalableMatrixWithUnitPricing != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isNewFloatingScalableMatrixWithTieredPricing(): Boolean = - newFloatingScalableMatrixWithTieredPricing != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isNewFloatingCumulativeGroupedBulk(): Boolean = - newFloatingCumulativeGroupedBulk != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun asNewFloatingUnit(): NewFloatingUnitPrice = - newFloatingUnit.getOrThrow("newFloatingUnit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asNewFloatingPackage(): NewFloatingPackagePrice = - newFloatingPackage.getOrThrow("newFloatingPackage") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asNewFloatingMatrix(): NewFloatingMatrixPrice = - newFloatingMatrix.getOrThrow("newFloatingMatrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asNewFloatingMatrixWithAllocation(): NewFloatingMatrixWithAllocationPrice = - newFloatingMatrixWithAllocation.getOrThrow("newFloatingMatrixWithAllocation") + fun asMatrixWithAllocation(): MatrixWithAllocation = + matrixWithAllocation.getOrThrow("matrixWithAllocation") - fun asNewFloatingTiered(): NewFloatingTieredPrice = - newFloatingTiered.getOrThrow("newFloatingTiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asNewFloatingTieredBps(): NewFloatingTieredBpsPrice = - newFloatingTieredBps.getOrThrow("newFloatingTieredBps") + fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - fun asNewFloatingBps(): NewFloatingBpsPrice = - newFloatingBps.getOrThrow("newFloatingBps") + fun asBps(): Bps = bps.getOrThrow("bps") - fun asNewFloatingBulkBps(): NewFloatingBulkBpsPrice = - newFloatingBulkBps.getOrThrow("newFloatingBulkBps") + fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") - fun asNewFloatingBulk(): NewFloatingBulkPrice = - newFloatingBulk.getOrThrow("newFloatingBulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") - fun asNewFloatingThresholdTotalAmount(): NewFloatingThresholdTotalAmountPrice = - newFloatingThresholdTotalAmount.getOrThrow("newFloatingThresholdTotalAmount") + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asNewFloatingTieredPackage(): NewFloatingTieredPackagePrice = - newFloatingTieredPackage.getOrThrow("newFloatingTieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asNewFloatingGroupedTiered(): NewFloatingGroupedTieredPrice = - newFloatingGroupedTiered.getOrThrow("newFloatingGroupedTiered") + fun asGroupedTiered(): GroupedTiered = groupedTiered.getOrThrow("groupedTiered") - fun asNewFloatingMaxGroupTieredPackage(): NewFloatingMaxGroupTieredPackagePrice = - newFloatingMaxGroupTieredPackage.getOrThrow("newFloatingMaxGroupTieredPackage") + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asNewFloatingTieredWithMinimum(): NewFloatingTieredWithMinimumPrice = - newFloatingTieredWithMinimum.getOrThrow("newFloatingTieredWithMinimum") + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asNewFloatingPackageWithAllocation(): NewFloatingPackageWithAllocationPrice = - newFloatingPackageWithAllocation.getOrThrow("newFloatingPackageWithAllocation") + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") - fun asNewFloatingTieredPackageWithMinimum(): NewFloatingTieredPackageWithMinimumPrice = - newFloatingTieredPackageWithMinimum.getOrThrow( - "newFloatingTieredPackageWithMinimum" - ) + fun asTieredPackageWithMinimum(): TieredPackageWithMinimum = + tieredPackageWithMinimum.getOrThrow("tieredPackageWithMinimum") - fun asNewFloatingUnitWithPercent(): NewFloatingUnitWithPercentPrice = - newFloatingUnitWithPercent.getOrThrow("newFloatingUnitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asNewFloatingTieredWithProration(): NewFloatingTieredWithProrationPrice = - newFloatingTieredWithProration.getOrThrow("newFloatingTieredWithProration") + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") - fun asNewFloatingUnitWithProration(): NewFloatingUnitWithProrationPrice = - newFloatingUnitWithProration.getOrThrow("newFloatingUnitWithProration") + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") - fun asNewFloatingGroupedAllocation(): NewFloatingGroupedAllocationPrice = - newFloatingGroupedAllocation.getOrThrow("newFloatingGroupedAllocation") + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") - fun asNewFloatingGroupedWithProratedMinimum(): - NewFloatingGroupedWithProratedMinimumPrice = - newFloatingGroupedWithProratedMinimum.getOrThrow( - "newFloatingGroupedWithProratedMinimum" - ) + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asNewFloatingGroupedWithMeteredMinimum(): - NewFloatingGroupedWithMeteredMinimumPrice = - newFloatingGroupedWithMeteredMinimum.getOrThrow( - "newFloatingGroupedWithMeteredMinimum" - ) + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - fun asNewFloatingMatrixWithDisplayName(): NewFloatingMatrixWithDisplayNamePrice = - newFloatingMatrixWithDisplayName.getOrThrow("newFloatingMatrixWithDisplayName") + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asNewFloatingBulkWithProration(): NewFloatingBulkWithProrationPrice = - newFloatingBulkWithProration.getOrThrow("newFloatingBulkWithProration") + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") - fun asNewFloatingGroupedTieredPackage(): NewFloatingGroupedTieredPackagePrice = - newFloatingGroupedTieredPackage.getOrThrow("newFloatingGroupedTieredPackage") + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") - fun asNewFloatingScalableMatrixWithUnitPricing(): - NewFloatingScalableMatrixWithUnitPricingPrice = - newFloatingScalableMatrixWithUnitPricing.getOrThrow( - "newFloatingScalableMatrixWithUnitPricing" - ) + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asNewFloatingScalableMatrixWithTieredPricing(): - NewFloatingScalableMatrixWithTieredPricingPrice = - newFloatingScalableMatrixWithTieredPricing.getOrThrow( - "newFloatingScalableMatrixWithTieredPricing" - ) + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asNewFloatingCumulativeGroupedBulk(): NewFloatingCumulativeGroupedBulkPrice = - newFloatingCumulativeGroupedBulk.getOrThrow("newFloatingCumulativeGroupedBulk") + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newFloatingUnit != null -> visitor.visitNewFloatingUnit(newFloatingUnit) - newFloatingPackage != null -> - visitor.visitNewFloatingPackage(newFloatingPackage) - newFloatingMatrix != null -> visitor.visitNewFloatingMatrix(newFloatingMatrix) - newFloatingMatrixWithAllocation != null -> - visitor.visitNewFloatingMatrixWithAllocation( - newFloatingMatrixWithAllocation - ) - newFloatingTiered != null -> visitor.visitNewFloatingTiered(newFloatingTiered) - newFloatingTieredBps != null -> - visitor.visitNewFloatingTieredBps(newFloatingTieredBps) - newFloatingBps != null -> visitor.visitNewFloatingBps(newFloatingBps) - newFloatingBulkBps != null -> - visitor.visitNewFloatingBulkBps(newFloatingBulkBps) - newFloatingBulk != null -> visitor.visitNewFloatingBulk(newFloatingBulk) - newFloatingThresholdTotalAmount != null -> - visitor.visitNewFloatingThresholdTotalAmount( - newFloatingThresholdTotalAmount - ) - newFloatingTieredPackage != null -> - visitor.visitNewFloatingTieredPackage(newFloatingTieredPackage) - newFloatingGroupedTiered != null -> - visitor.visitNewFloatingGroupedTiered(newFloatingGroupedTiered) - newFloatingMaxGroupTieredPackage != null -> - visitor.visitNewFloatingMaxGroupTieredPackage( - newFloatingMaxGroupTieredPackage - ) - newFloatingTieredWithMinimum != null -> - visitor.visitNewFloatingTieredWithMinimum(newFloatingTieredWithMinimum) - newFloatingPackageWithAllocation != null -> - visitor.visitNewFloatingPackageWithAllocation( - newFloatingPackageWithAllocation - ) - newFloatingTieredPackageWithMinimum != null -> - visitor.visitNewFloatingTieredPackageWithMinimum( - newFloatingTieredPackageWithMinimum - ) - newFloatingUnitWithPercent != null -> - visitor.visitNewFloatingUnitWithPercent(newFloatingUnitWithPercent) - newFloatingTieredWithProration != null -> - visitor.visitNewFloatingTieredWithProration(newFloatingTieredWithProration) - newFloatingUnitWithProration != null -> - visitor.visitNewFloatingUnitWithProration(newFloatingUnitWithProration) - newFloatingGroupedAllocation != null -> - visitor.visitNewFloatingGroupedAllocation(newFloatingGroupedAllocation) - newFloatingGroupedWithProratedMinimum != null -> - visitor.visitNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum - ) - newFloatingGroupedWithMeteredMinimum != null -> - visitor.visitNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum - ) - newFloatingMatrixWithDisplayName != null -> - visitor.visitNewFloatingMatrixWithDisplayName( - newFloatingMatrixWithDisplayName - ) - newFloatingBulkWithProration != null -> - visitor.visitNewFloatingBulkWithProration(newFloatingBulkWithProration) - newFloatingGroupedTieredPackage != null -> - visitor.visitNewFloatingGroupedTieredPackage( - newFloatingGroupedTieredPackage - ) - newFloatingScalableMatrixWithUnitPricing != null -> - visitor.visitNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing - ) - newFloatingScalableMatrixWithTieredPricing != null -> - visitor.visitNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing - ) - newFloatingCumulativeGroupedBulk != null -> - visitor.visitNewFloatingCumulativeGroupedBulk( - newFloatingCumulativeGroupedBulk + 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) + 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) + tieredPackageWithMinimum != null -> + visitor.visitTieredPackageWithMinimum(tieredPackageWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + 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) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) else -> visitor.unknown(_json) } @@ -4702,172 +4021,143 @@ private constructor( } accept( - object : Visitor { - override fun visitNewFloatingUnit(newFloatingUnit: NewFloatingUnitPrice) { - newFloatingUnit.validate() + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() } - override fun visitNewFloatingPackage( - newFloatingPackage: NewFloatingPackagePrice - ) { - newFloatingPackage.validate() + override fun visitPackage(package_: Package) { + package_.validate() } - override fun visitNewFloatingMatrix( - newFloatingMatrix: NewFloatingMatrixPrice - ) { - newFloatingMatrix.validate() + override fun visitMatrix(matrix: Matrix) { + matrix.validate() } - override fun visitNewFloatingMatrixWithAllocation( - newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation ) { - newFloatingMatrixWithAllocation.validate() + matrixWithAllocation.validate() } - override fun visitNewFloatingTiered( - newFloatingTiered: NewFloatingTieredPrice - ) { - newFloatingTiered.validate() + override fun visitTiered(tiered: Tiered) { + tiered.validate() } - override fun visitNewFloatingTieredBps( - newFloatingTieredBps: NewFloatingTieredBpsPrice - ) { - newFloatingTieredBps.validate() + override fun visitTieredBps(tieredBps: TieredBps) { + tieredBps.validate() } - override fun visitNewFloatingBps(newFloatingBps: NewFloatingBpsPrice) { - newFloatingBps.validate() + override fun visitBps(bps: Bps) { + bps.validate() } - override fun visitNewFloatingBulkBps( - newFloatingBulkBps: NewFloatingBulkBpsPrice - ) { - newFloatingBulkBps.validate() + override fun visitBulkBps(bulkBps: BulkBps) { + bulkBps.validate() } - override fun visitNewFloatingBulk(newFloatingBulk: NewFloatingBulkPrice) { - newFloatingBulk.validate() + override fun visitBulk(bulk: Bulk) { + bulk.validate() } - override fun visitNewFloatingThresholdTotalAmount( - newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount ) { - newFloatingThresholdTotalAmount.validate() + thresholdTotalAmount.validate() } - override fun visitNewFloatingTieredPackage( - newFloatingTieredPackage: NewFloatingTieredPackagePrice - ) { - newFloatingTieredPackage.validate() + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() } - override fun visitNewFloatingGroupedTiered( - newFloatingGroupedTiered: NewFloatingGroupedTieredPrice - ) { - newFloatingGroupedTiered.validate() + override fun visitGroupedTiered(groupedTiered: GroupedTiered) { + groupedTiered.validate() } - override fun visitNewFloatingMaxGroupTieredPackage( - newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage ) { - newFloatingMaxGroupTieredPackage.validate() + maxGroupTieredPackage.validate() } - override fun visitNewFloatingTieredWithMinimum( - newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice - ) { - newFloatingTieredWithMinimum.validate() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() } - override fun visitNewFloatingPackageWithAllocation( - newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation ) { - newFloatingPackageWithAllocation.validate() + packageWithAllocation.validate() } - override fun visitNewFloatingTieredPackageWithMinimum( - newFloatingTieredPackageWithMinimum: - NewFloatingTieredPackageWithMinimumPrice + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum ) { - newFloatingTieredPackageWithMinimum.validate() + tieredPackageWithMinimum.validate() } - override fun visitNewFloatingUnitWithPercent( - newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice - ) { - newFloatingUnitWithPercent.validate() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() } - override fun visitNewFloatingTieredWithProration( - newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration ) { - newFloatingTieredWithProration.validate() + tieredWithProration.validate() } - override fun visitNewFloatingUnitWithProration( - newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice - ) { - newFloatingUnitWithProration.validate() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() } - override fun visitNewFloatingGroupedAllocation( - newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice - ) { - newFloatingGroupedAllocation.validate() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() } - override fun visitNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum: - NewFloatingGroupedWithProratedMinimumPrice + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { - newFloatingGroupedWithProratedMinimum.validate() + groupedWithProratedMinimum.validate() } - override fun visitNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum: - NewFloatingGroupedWithMeteredMinimumPrice + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { - newFloatingGroupedWithMeteredMinimum.validate() + groupedWithMeteredMinimum.validate() } - override fun visitNewFloatingMatrixWithDisplayName( - newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName ) { - newFloatingMatrixWithDisplayName.validate() + matrixWithDisplayName.validate() } - override fun visitNewFloatingBulkWithProration( - newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice - ) { - newFloatingBulkWithProration.validate() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() } - override fun visitNewFloatingGroupedTieredPackage( - newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage ) { - newFloatingGroupedTieredPackage.validate() + groupedTieredPackage.validate() } - override fun visitNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing: - NewFloatingScalableMatrixWithUnitPricingPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { - newFloatingScalableMatrixWithUnitPricing.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing: - NewFloatingScalableMatrixWithTieredPricingPrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { - newFloatingScalableMatrixWithTieredPricing.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitNewFloatingCumulativeGroupedBulk( - newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk ) { - newFloatingCumulativeGroupedBulk.validate() + cumulativeGroupedBulk.validate() } } ) @@ -4892,119 +4182,94 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewFloatingUnit(newFloatingUnit: NewFloatingUnitPrice) = - newFloatingUnit.validity() + override fun visitUnit(unit: Unit) = unit.validity() - override fun visitNewFloatingPackage( - newFloatingPackage: NewFloatingPackagePrice - ) = newFloatingPackage.validity() + override fun visitPackage(package_: Package) = package_.validity() - override fun visitNewFloatingMatrix( - newFloatingMatrix: NewFloatingMatrixPrice - ) = newFloatingMatrix.validity() + override fun visitMatrix(matrix: Matrix) = matrix.validity() - override fun visitNewFloatingMatrixWithAllocation( - newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = newFloatingMatrixWithAllocation.validity() + override fun visitMatrixWithAllocation( + matrixWithAllocation: MatrixWithAllocation + ) = matrixWithAllocation.validity() - override fun visitNewFloatingTiered( - newFloatingTiered: NewFloatingTieredPrice - ) = newFloatingTiered.validity() + override fun visitTiered(tiered: Tiered) = tiered.validity() - override fun visitNewFloatingTieredBps( - newFloatingTieredBps: NewFloatingTieredBpsPrice - ) = newFloatingTieredBps.validity() + override fun visitTieredBps(tieredBps: TieredBps) = tieredBps.validity() - override fun visitNewFloatingBps(newFloatingBps: NewFloatingBpsPrice) = - newFloatingBps.validity() + override fun visitBps(bps: Bps) = bps.validity() - override fun visitNewFloatingBulkBps( - newFloatingBulkBps: NewFloatingBulkBpsPrice - ) = newFloatingBulkBps.validity() + override fun visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() - override fun visitNewFloatingBulk(newFloatingBulk: NewFloatingBulkPrice) = - newFloatingBulk.validity() + override fun visitBulk(bulk: Bulk) = bulk.validity() - override fun visitNewFloatingThresholdTotalAmount( - newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice - ) = newFloatingThresholdTotalAmount.validity() + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() - override fun visitNewFloatingTieredPackage( - newFloatingTieredPackage: NewFloatingTieredPackagePrice - ) = newFloatingTieredPackage.validity() + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() - override fun visitNewFloatingGroupedTiered( - newFloatingGroupedTiered: NewFloatingGroupedTieredPrice - ) = newFloatingGroupedTiered.validity() + override fun visitGroupedTiered(groupedTiered: GroupedTiered) = + groupedTiered.validity() - override fun visitNewFloatingMaxGroupTieredPackage( - newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = newFloatingMaxGroupTieredPackage.validity() + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() - override fun visitNewFloatingTieredWithMinimum( - newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice - ) = newFloatingTieredWithMinimum.validity() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() - override fun visitNewFloatingPackageWithAllocation( - newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = newFloatingPackageWithAllocation.validity() + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() - override fun visitNewFloatingTieredPackageWithMinimum( - newFloatingTieredPackageWithMinimum: - NewFloatingTieredPackageWithMinimumPrice - ) = newFloatingTieredPackageWithMinimum.validity() + override fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum + ) = tieredPackageWithMinimum.validity() - override fun visitNewFloatingUnitWithPercent( - newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice - ) = newFloatingUnitWithPercent.validity() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() - override fun visitNewFloatingTieredWithProration( - newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice - ) = newFloatingTieredWithProration.validity() + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() - override fun visitNewFloatingUnitWithProration( - newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice - ) = newFloatingUnitWithProration.validity() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() - override fun visitNewFloatingGroupedAllocation( - newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice - ) = newFloatingGroupedAllocation.validity() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() - override fun visitNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum: - NewFloatingGroupedWithProratedMinimumPrice - ) = newFloatingGroupedWithProratedMinimum.validity() + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() - override fun visitNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum: - NewFloatingGroupedWithMeteredMinimumPrice - ) = newFloatingGroupedWithMeteredMinimum.validity() + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() - override fun visitNewFloatingMatrixWithDisplayName( - newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice - ) = newFloatingMatrixWithDisplayName.validity() + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() - override fun visitNewFloatingBulkWithProration( - newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice - ) = newFloatingBulkWithProration.validity() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() - override fun visitNewFloatingGroupedTieredPackage( - newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice - ) = newFloatingGroupedTieredPackage.validity() + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() - override fun visitNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing: - NewFloatingScalableMatrixWithUnitPricingPrice - ) = newFloatingScalableMatrixWithUnitPricing.validity() + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() - override fun visitNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing: - NewFloatingScalableMatrixWithTieredPricingPrice - ) = newFloatingScalableMatrixWithTieredPricing.validity() + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() - override fun visitNewFloatingCumulativeGroupedBulk( - newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice - ) = newFloatingCumulativeGroupedBulk.validity() + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5015,217 +4280,158 @@ private constructor( return true } - return /* spotless:off */ other is Price && newFloatingUnit == other.newFloatingUnit && newFloatingPackage == other.newFloatingPackage && newFloatingMatrix == other.newFloatingMatrix && newFloatingMatrixWithAllocation == other.newFloatingMatrixWithAllocation && newFloatingTiered == other.newFloatingTiered && newFloatingTieredBps == other.newFloatingTieredBps && newFloatingBps == other.newFloatingBps && newFloatingBulkBps == other.newFloatingBulkBps && newFloatingBulk == other.newFloatingBulk && newFloatingThresholdTotalAmount == other.newFloatingThresholdTotalAmount && newFloatingTieredPackage == other.newFloatingTieredPackage && newFloatingGroupedTiered == other.newFloatingGroupedTiered && newFloatingMaxGroupTieredPackage == other.newFloatingMaxGroupTieredPackage && newFloatingTieredWithMinimum == other.newFloatingTieredWithMinimum && newFloatingPackageWithAllocation == other.newFloatingPackageWithAllocation && newFloatingTieredPackageWithMinimum == other.newFloatingTieredPackageWithMinimum && newFloatingUnitWithPercent == other.newFloatingUnitWithPercent && newFloatingTieredWithProration == other.newFloatingTieredWithProration && newFloatingUnitWithProration == other.newFloatingUnitWithProration && newFloatingGroupedAllocation == other.newFloatingGroupedAllocation && newFloatingGroupedWithProratedMinimum == other.newFloatingGroupedWithProratedMinimum && newFloatingGroupedWithMeteredMinimum == other.newFloatingGroupedWithMeteredMinimum && newFloatingMatrixWithDisplayName == other.newFloatingMatrixWithDisplayName && newFloatingBulkWithProration == other.newFloatingBulkWithProration && newFloatingGroupedTieredPackage == other.newFloatingGroupedTieredPackage && newFloatingScalableMatrixWithUnitPricing == other.newFloatingScalableMatrixWithUnitPricing && newFloatingScalableMatrixWithTieredPricing == other.newFloatingScalableMatrixWithTieredPricing && newFloatingCumulativeGroupedBulk == other.newFloatingCumulativeGroupedBulk /* spotless:on */ + 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(newFloatingUnit, newFloatingPackage, newFloatingMatrix, newFloatingMatrixWithAllocation, newFloatingTiered, newFloatingTieredBps, newFloatingBps, newFloatingBulkBps, newFloatingBulk, newFloatingThresholdTotalAmount, newFloatingTieredPackage, newFloatingGroupedTiered, newFloatingMaxGroupTieredPackage, newFloatingTieredWithMinimum, newFloatingPackageWithAllocation, newFloatingTieredPackageWithMinimum, newFloatingUnitWithPercent, newFloatingTieredWithProration, newFloatingUnitWithProration, newFloatingGroupedAllocation, newFloatingGroupedWithProratedMinimum, newFloatingGroupedWithMeteredMinimum, newFloatingMatrixWithDisplayName, newFloatingBulkWithProration, newFloatingGroupedTieredPackage, newFloatingScalableMatrixWithUnitPricing, newFloatingScalableMatrixWithTieredPricing, newFloatingCumulativeGroupedBulk) /* 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 */ override fun toString(): String = when { - newFloatingUnit != null -> "Price{newFloatingUnit=$newFloatingUnit}" - newFloatingPackage != null -> "Price{newFloatingPackage=$newFloatingPackage}" - newFloatingMatrix != null -> "Price{newFloatingMatrix=$newFloatingMatrix}" - newFloatingMatrixWithAllocation != null -> - "Price{newFloatingMatrixWithAllocation=$newFloatingMatrixWithAllocation}" - newFloatingTiered != null -> "Price{newFloatingTiered=$newFloatingTiered}" - newFloatingTieredBps != null -> - "Price{newFloatingTieredBps=$newFloatingTieredBps}" - newFloatingBps != null -> "Price{newFloatingBps=$newFloatingBps}" - newFloatingBulkBps != null -> "Price{newFloatingBulkBps=$newFloatingBulkBps}" - newFloatingBulk != null -> "Price{newFloatingBulk=$newFloatingBulk}" - newFloatingThresholdTotalAmount != null -> - "Price{newFloatingThresholdTotalAmount=$newFloatingThresholdTotalAmount}" - newFloatingTieredPackage != null -> - "Price{newFloatingTieredPackage=$newFloatingTieredPackage}" - newFloatingGroupedTiered != null -> - "Price{newFloatingGroupedTiered=$newFloatingGroupedTiered}" - newFloatingMaxGroupTieredPackage != null -> - "Price{newFloatingMaxGroupTieredPackage=$newFloatingMaxGroupTieredPackage}" - newFloatingTieredWithMinimum != null -> - "Price{newFloatingTieredWithMinimum=$newFloatingTieredWithMinimum}" - newFloatingPackageWithAllocation != null -> - "Price{newFloatingPackageWithAllocation=$newFloatingPackageWithAllocation}" - newFloatingTieredPackageWithMinimum != null -> - "Price{newFloatingTieredPackageWithMinimum=$newFloatingTieredPackageWithMinimum}" - newFloatingUnitWithPercent != null -> - "Price{newFloatingUnitWithPercent=$newFloatingUnitWithPercent}" - newFloatingTieredWithProration != null -> - "Price{newFloatingTieredWithProration=$newFloatingTieredWithProration}" - newFloatingUnitWithProration != null -> - "Price{newFloatingUnitWithProration=$newFloatingUnitWithProration}" - newFloatingGroupedAllocation != null -> - "Price{newFloatingGroupedAllocation=$newFloatingGroupedAllocation}" - newFloatingGroupedWithProratedMinimum != null -> - "Price{newFloatingGroupedWithProratedMinimum=$newFloatingGroupedWithProratedMinimum}" - newFloatingGroupedWithMeteredMinimum != null -> - "Price{newFloatingGroupedWithMeteredMinimum=$newFloatingGroupedWithMeteredMinimum}" - newFloatingMatrixWithDisplayName != null -> - "Price{newFloatingMatrixWithDisplayName=$newFloatingMatrixWithDisplayName}" - newFloatingBulkWithProration != null -> - "Price{newFloatingBulkWithProration=$newFloatingBulkWithProration}" - newFloatingGroupedTieredPackage != null -> - "Price{newFloatingGroupedTieredPackage=$newFloatingGroupedTieredPackage}" - newFloatingScalableMatrixWithUnitPricing != null -> - "Price{newFloatingScalableMatrixWithUnitPricing=$newFloatingScalableMatrixWithUnitPricing}" - newFloatingScalableMatrixWithTieredPricing != null -> - "Price{newFloatingScalableMatrixWithTieredPricing=$newFloatingScalableMatrixWithTieredPricing}" - newFloatingCumulativeGroupedBulk != null -> - "Price{newFloatingCumulativeGroupedBulk=$newFloatingCumulativeGroupedBulk}" + 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}" + 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}" + tieredPackageWithMinimum != null -> + "Price{tieredPackageWithMinimum=$tieredPackageWithMinimum}" + unitWithPercent != null -> "Price{unitWithPercent=$unitWithPercent}" + 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}" + scalableMatrixWithUnitPricing != null -> + "Price{scalableMatrixWithUnitPricing=$scalableMatrixWithUnitPricing}" + scalableMatrixWithTieredPricing != null -> + "Price{scalableMatrixWithTieredPricing=$scalableMatrixWithTieredPricing}" + cumulativeGroupedBulk != null -> + "Price{cumulativeGroupedBulk=$cumulativeGroupedBulk}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } companion object { - @JvmStatic - fun ofNewFloatingUnit(newFloatingUnit: NewFloatingUnitPrice) = - Price(newFloatingUnit = newFloatingUnit) + @JvmStatic fun ofUnit(unit: Unit) = Price(unit = unit) - @JvmStatic - fun ofNewFloatingPackage(newFloatingPackage: NewFloatingPackagePrice) = - Price(newFloatingPackage = newFloatingPackage) + @JvmStatic fun ofPackage(package_: Package) = Price(package_ = package_) - @JvmStatic - fun ofNewFloatingMatrix(newFloatingMatrix: NewFloatingMatrixPrice) = - Price(newFloatingMatrix = newFloatingMatrix) + @JvmStatic fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) @JvmStatic - fun ofNewFloatingMatrixWithAllocation( - newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ) = Price(newFloatingMatrixWithAllocation = newFloatingMatrixWithAllocation) + fun ofMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation) = + Price(matrixWithAllocation = matrixWithAllocation) - @JvmStatic - fun ofNewFloatingTiered(newFloatingTiered: NewFloatingTieredPrice) = - Price(newFloatingTiered = newFloatingTiered) + @JvmStatic fun ofTiered(tiered: Tiered) = Price(tiered = tiered) - @JvmStatic - fun ofNewFloatingTieredBps(newFloatingTieredBps: NewFloatingTieredBpsPrice) = - Price(newFloatingTieredBps = newFloatingTieredBps) + @JvmStatic fun ofTieredBps(tieredBps: TieredBps) = Price(tieredBps = tieredBps) - @JvmStatic - fun ofNewFloatingBps(newFloatingBps: NewFloatingBpsPrice) = - Price(newFloatingBps = newFloatingBps) + @JvmStatic fun ofBps(bps: Bps) = Price(bps = bps) - @JvmStatic - fun ofNewFloatingBulkBps(newFloatingBulkBps: NewFloatingBulkBpsPrice) = - Price(newFloatingBulkBps = newFloatingBulkBps) + @JvmStatic fun ofBulkBps(bulkBps: BulkBps) = Price(bulkBps = bulkBps) - @JvmStatic - fun ofNewFloatingBulk(newFloatingBulk: NewFloatingBulkPrice) = - Price(newFloatingBulk = newFloatingBulk) + @JvmStatic fun ofBulk(bulk: Bulk) = Price(bulk = bulk) @JvmStatic - fun ofNewFloatingThresholdTotalAmount( - newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice - ) = Price(newFloatingThresholdTotalAmount = newFloatingThresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + Price(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofNewFloatingTieredPackage( - newFloatingTieredPackage: NewFloatingTieredPackagePrice - ) = Price(newFloatingTieredPackage = newFloatingTieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + Price(tieredPackage = tieredPackage) @JvmStatic - fun ofNewFloatingGroupedTiered( - newFloatingGroupedTiered: NewFloatingGroupedTieredPrice - ) = Price(newFloatingGroupedTiered = newFloatingGroupedTiered) + fun ofGroupedTiered(groupedTiered: GroupedTiered) = + Price(groupedTiered = groupedTiered) @JvmStatic - fun ofNewFloatingMaxGroupTieredPackage( - newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ) = Price(newFloatingMaxGroupTieredPackage = newFloatingMaxGroupTieredPackage) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + Price(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic - fun ofNewFloatingTieredWithMinimum( - newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice - ) = Price(newFloatingTieredWithMinimum = newFloatingTieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofNewFloatingPackageWithAllocation( - newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice - ) = Price(newFloatingPackageWithAllocation = newFloatingPackageWithAllocation) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofNewFloatingTieredPackageWithMinimum( - newFloatingTieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice - ) = Price(newFloatingTieredPackageWithMinimum = newFloatingTieredPackageWithMinimum) + fun ofTieredPackageWithMinimum(tieredPackageWithMinimum: TieredPackageWithMinimum) = + Price(tieredPackageWithMinimum = tieredPackageWithMinimum) @JvmStatic - fun ofNewFloatingUnitWithPercent( - newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice - ) = Price(newFloatingUnitWithPercent = newFloatingUnitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + Price(unitWithPercent = unitWithPercent) @JvmStatic - fun ofNewFloatingTieredWithProration( - newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice - ) = Price(newFloatingTieredWithProration = newFloatingTieredWithProration) + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) @JvmStatic - fun ofNewFloatingUnitWithProration( - newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice - ) = Price(newFloatingUnitWithProration = newFloatingUnitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + Price(unitWithProration = unitWithProration) @JvmStatic - fun ofNewFloatingGroupedAllocation( - newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice - ) = Price(newFloatingGroupedAllocation = newFloatingGroupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + Price(groupedAllocation = groupedAllocation) @JvmStatic - fun ofNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum: - NewFloatingGroupedWithProratedMinimumPrice - ) = - Price( - newFloatingGroupedWithProratedMinimum = - newFloatingGroupedWithProratedMinimum - ) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice - ) = - Price( - newFloatingGroupedWithMeteredMinimum = newFloatingGroupedWithMeteredMinimum - ) + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofNewFloatingMatrixWithDisplayName( - newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice - ) = Price(newFloatingMatrixWithDisplayName = newFloatingMatrixWithDisplayName) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofNewFloatingBulkWithProration( - newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice - ) = Price(newFloatingBulkWithProration = newFloatingBulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + Price(bulkWithProration = bulkWithProration) @JvmStatic - fun ofNewFloatingGroupedTieredPackage( - newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice - ) = Price(newFloatingGroupedTieredPackage = newFloatingGroupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + Price(groupedTieredPackage = groupedTieredPackage) @JvmStatic - fun ofNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing: - NewFloatingScalableMatrixWithUnitPricingPrice - ) = - Price( - newFloatingScalableMatrixWithUnitPricing = - newFloatingScalableMatrixWithUnitPricing - ) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic - fun ofNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing: - NewFloatingScalableMatrixWithTieredPricingPrice - ) = - Price( - newFloatingScalableMatrixWithTieredPricing = - newFloatingScalableMatrixWithTieredPricing - ) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofNewFloatingCumulativeGroupedBulk( - newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice - ) = Price(newFloatingCumulativeGroupedBulk = newFloatingCumulativeGroupedBulk) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + Price(cumulativeGroupedBulk = cumulativeGroupedBulk) } /** @@ -5233,104 +4439,71 @@ private constructor( */ interface Visitor { - fun visitNewFloatingUnit(newFloatingUnit: NewFloatingUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitNewFloatingPackage(newFloatingPackage: NewFloatingPackagePrice): T + fun visitPackage(package_: Package): T - fun visitNewFloatingMatrix(newFloatingMatrix: NewFloatingMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitNewFloatingMatrixWithAllocation( - newFloatingMatrixWithAllocation: NewFloatingMatrixWithAllocationPrice - ): T + fun visitMatrixWithAllocation(matrixWithAllocation: MatrixWithAllocation): T - fun visitNewFloatingTiered(newFloatingTiered: NewFloatingTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitNewFloatingTieredBps(newFloatingTieredBps: NewFloatingTieredBpsPrice): T + fun visitTieredBps(tieredBps: TieredBps): T - fun visitNewFloatingBps(newFloatingBps: NewFloatingBpsPrice): T + fun visitBps(bps: Bps): T - fun visitNewFloatingBulkBps(newFloatingBulkBps: NewFloatingBulkBpsPrice): T + fun visitBulkBps(bulkBps: BulkBps): T - fun visitNewFloatingBulk(newFloatingBulk: NewFloatingBulkPrice): T + fun visitBulk(bulk: Bulk): T - fun visitNewFloatingThresholdTotalAmount( - newFloatingThresholdTotalAmount: NewFloatingThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitNewFloatingTieredPackage( - newFloatingTieredPackage: NewFloatingTieredPackagePrice - ): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitNewFloatingGroupedTiered( - newFloatingGroupedTiered: NewFloatingGroupedTieredPrice - ): T + fun visitGroupedTiered(groupedTiered: GroupedTiered): T - fun visitNewFloatingMaxGroupTieredPackage( - newFloatingMaxGroupTieredPackage: NewFloatingMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T - fun visitNewFloatingTieredWithMinimum( - newFloatingTieredWithMinimum: NewFloatingTieredWithMinimumPrice - ): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitNewFloatingPackageWithAllocation( - newFloatingPackageWithAllocation: NewFloatingPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitNewFloatingTieredPackageWithMinimum( - newFloatingTieredPackageWithMinimum: NewFloatingTieredPackageWithMinimumPrice + fun visitTieredPackageWithMinimum( + tieredPackageWithMinimum: TieredPackageWithMinimum ): T - fun visitNewFloatingUnitWithPercent( - newFloatingUnitWithPercent: NewFloatingUnitWithPercentPrice - ): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitNewFloatingTieredWithProration( - newFloatingTieredWithProration: NewFloatingTieredWithProrationPrice - ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitNewFloatingUnitWithProration( - newFloatingUnitWithProration: NewFloatingUnitWithProrationPrice - ): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitNewFloatingGroupedAllocation( - newFloatingGroupedAllocation: NewFloatingGroupedAllocationPrice - ): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitNewFloatingGroupedWithProratedMinimum( - newFloatingGroupedWithProratedMinimum: - NewFloatingGroupedWithProratedMinimumPrice + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T - fun visitNewFloatingGroupedWithMeteredMinimum( - newFloatingGroupedWithMeteredMinimum: NewFloatingGroupedWithMeteredMinimumPrice + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T - fun visitNewFloatingMatrixWithDisplayName( - newFloatingMatrixWithDisplayName: NewFloatingMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitNewFloatingBulkWithProration( - newFloatingBulkWithProration: NewFloatingBulkWithProrationPrice - ): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T - fun visitNewFloatingGroupedTieredPackage( - newFloatingGroupedTieredPackage: NewFloatingGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T - fun visitNewFloatingScalableMatrixWithUnitPricing( - newFloatingScalableMatrixWithUnitPricing: - NewFloatingScalableMatrixWithUnitPricingPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T - fun visitNewFloatingScalableMatrixWithTieredPricing( - newFloatingScalableMatrixWithTieredPricing: - NewFloatingScalableMatrixWithTieredPricingPrice + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitNewFloatingCumulativeGroupedBulk( - newFloatingCumulativeGroupedBulk: NewFloatingCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -5356,216 +4529,152 @@ private constructor( when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newFloatingUnit = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } "package" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newFloatingPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(package_ = it, _json = json) + } ?: Price(_json = json) } "matrix" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newFloatingMatrix = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) } "matrix_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingMatrixWithAllocation = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrixWithAllocation = it, _json = json) } ?: Price(_json = json) } "tiered" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newFloatingTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } "tiered_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newFloatingTieredBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredBps = it, _json = json) + } ?: Price(_json = json) } "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newFloatingBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bps = it, _json = json) + } ?: Price(_json = json) } "bulk_bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newFloatingBulkBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkBps = it, _json = json) + } ?: Price(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newFloatingBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingThresholdTotalAmount = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(thresholdTotalAmount = it, _json = json) } ?: Price(_json = json) } "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredPackage = it, _json = json) + } ?: Price(_json = json) } "grouped_tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingGroupedTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedTiered = it, _json = json) + } ?: Price(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingMaxGroupTieredPackage = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } ?: Price(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingTieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredWithMinimum = it, _json = json) + } ?: Price(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingPackageWithAllocation = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(packageWithAllocation = it, _json = json) } ?: Price(_json = json) } "tiered_package_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newFloatingTieredPackageWithMinimum = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredPackageWithMinimum = it, _json = json) } + ?: Price(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingUnitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithPercent = it, _json = json) + } ?: Price(_json = json) } "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingTieredWithProration = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingUnitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedAllocation = it, _json = json) + } ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { - Price(newFloatingGroupedWithProratedMinimum = it, _json = json) - } ?: Price(_json = json) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newFloatingGroupedWithMeteredMinimum = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingMatrixWithDisplayName = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrixWithDisplayName = it, _json = json) } ?: Price(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingBulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingGroupedTieredPackage = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTieredPackage = it, _json = json) } ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { - Price( - newFloatingScalableMatrixWithUnitPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef< - NewFloatingScalableMatrixWithTieredPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { - Price( - newFloatingScalableMatrixWithTieredPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newFloatingCumulativeGroupedBulk = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } ?: Price(_json = json) } } @@ -5582,73 +4691,64 @@ private constructor( provider: SerializerProvider, ) { when { - value.newFloatingUnit != null -> - generator.writeObject(value.newFloatingUnit) - value.newFloatingPackage != null -> - generator.writeObject(value.newFloatingPackage) - value.newFloatingMatrix != null -> - generator.writeObject(value.newFloatingMatrix) - value.newFloatingMatrixWithAllocation != null -> - generator.writeObject(value.newFloatingMatrixWithAllocation) - value.newFloatingTiered != null -> - generator.writeObject(value.newFloatingTiered) - value.newFloatingTieredBps != null -> - generator.writeObject(value.newFloatingTieredBps) - value.newFloatingBps != null -> generator.writeObject(value.newFloatingBps) - value.newFloatingBulkBps != null -> - generator.writeObject(value.newFloatingBulkBps) - value.newFloatingBulk != null -> - generator.writeObject(value.newFloatingBulk) - value.newFloatingThresholdTotalAmount != null -> - generator.writeObject(value.newFloatingThresholdTotalAmount) - value.newFloatingTieredPackage != null -> - generator.writeObject(value.newFloatingTieredPackage) - value.newFloatingGroupedTiered != null -> - generator.writeObject(value.newFloatingGroupedTiered) - value.newFloatingMaxGroupTieredPackage != null -> - generator.writeObject(value.newFloatingMaxGroupTieredPackage) - value.newFloatingTieredWithMinimum != null -> - generator.writeObject(value.newFloatingTieredWithMinimum) - value.newFloatingPackageWithAllocation != null -> - generator.writeObject(value.newFloatingPackageWithAllocation) - value.newFloatingTieredPackageWithMinimum != null -> - generator.writeObject(value.newFloatingTieredPackageWithMinimum) - value.newFloatingUnitWithPercent != null -> - generator.writeObject(value.newFloatingUnitWithPercent) - value.newFloatingTieredWithProration != null -> - generator.writeObject(value.newFloatingTieredWithProration) - value.newFloatingUnitWithProration != null -> - generator.writeObject(value.newFloatingUnitWithProration) - value.newFloatingGroupedAllocation != null -> - generator.writeObject(value.newFloatingGroupedAllocation) - value.newFloatingGroupedWithProratedMinimum != null -> - generator.writeObject(value.newFloatingGroupedWithProratedMinimum) - value.newFloatingGroupedWithMeteredMinimum != null -> - generator.writeObject(value.newFloatingGroupedWithMeteredMinimum) - value.newFloatingMatrixWithDisplayName != null -> - generator.writeObject(value.newFloatingMatrixWithDisplayName) - value.newFloatingBulkWithProration != null -> - generator.writeObject(value.newFloatingBulkWithProration) - value.newFloatingGroupedTieredPackage != null -> - generator.writeObject(value.newFloatingGroupedTieredPackage) - value.newFloatingScalableMatrixWithUnitPricing != null -> - generator.writeObject(value.newFloatingScalableMatrixWithUnitPricing) - value.newFloatingScalableMatrixWithTieredPricing != null -> - generator.writeObject(value.newFloatingScalableMatrixWithTieredPricing) - value.newFloatingCumulativeGroupedBulk != null -> - generator.writeObject(value.newFloatingCumulativeGroupedBulk) + 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.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.tieredPackageWithMinimum != null -> + generator.writeObject(value.tieredPackageWithMinimum) + value.unitWithPercent != null -> + generator.writeObject(value.unitWithPercent) + 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.scalableMatrixWithUnitPricing != null -> + generator.writeObject(value.scalableMatrixWithUnitPricing) + value.scalableMatrixWithTieredPricing != null -> + generator.writeObject(value.scalableMatrixWithTieredPricing) + value.cumulativeGroupedBulk != null -> + generator.writeObject(value.cumulativeGroupedBulk) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - class NewFloatingUnitPrice + class Unit private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitConfig: JsonField, private val billableMetricId: JsonField, @@ -5676,7 +4776,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -5759,11 +4859,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -5896,16 +5000,6 @@ private constructor( */ @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]. * @@ -6031,15 +5125,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingUnitPrice]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` @@ -6047,13 +5139,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingUnitPrice]. */ + /** A builder for [Unit]. */ 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 modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -6071,25 +5163,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingUnitPrice: NewFloatingUnitPrice) = apply { - cadence = newFloatingUnitPrice.cadence - currency = newFloatingUnitPrice.currency - itemId = newFloatingUnitPrice.itemId - modelType = newFloatingUnitPrice.modelType - name = newFloatingUnitPrice.name - unitConfig = newFloatingUnitPrice.unitConfig - billableMetricId = newFloatingUnitPrice.billableMetricId - billedInAdvance = newFloatingUnitPrice.billedInAdvance - billingCycleConfiguration = newFloatingUnitPrice.billingCycleConfiguration - conversionRate = newFloatingUnitPrice.conversionRate - externalPriceId = newFloatingUnitPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitPrice.invoicingCycleConfiguration - metadata = newFloatingUnitPrice.metadata - additionalProperties = - newFloatingUnitPrice.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + currency = unit.currency + itemId = unit.itemId + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + metadata = unit.metadata + additionalProperties = unit.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -6128,18 +5218,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -6433,7 +5524,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingUnitPrice]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6442,19 +5533,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingUnitPrice = - NewFloatingUnitPrice( + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitConfig", unitConfig), billableMetricId, @@ -6472,7 +5562,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingUnitPrice = apply { + fun validate(): Unit = apply { if (validated) { return@apply } @@ -6480,7 +5570,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitConfig().validate() billableMetricId() @@ -6514,7 +5608,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -6686,135 +5780,6 @@ private constructor( 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 UNIT = of("unit") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT - } - - /** - * 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 { - UNIT, - /** - * 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) { - UNIT -> Value.UNIT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT -> Known.UNIT - 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 UnitConfig private constructor( private val unitAmount: JsonField, @@ -7824,7 +6789,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Unit && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7834,15 +6799,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingPackagePrice + class Package private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageConfig: JsonField, private val billableMetricId: JsonField, @@ -7870,7 +6835,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -7953,11 +6918,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -8090,16 +7059,6 @@ private constructor( */ @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]. * @@ -8225,15 +7184,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingPackagePrice]. + * Returns a mutable builder for constructing an instance of [Package]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` @@ -8241,13 +7198,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingPackagePrice]. */ + /** A builder for [Package]. */ 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 modelType: JsonValue = JsonValue.from("package") private var name: JsonField? = null private var packageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -8265,26 +7222,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingPackagePrice: NewFloatingPackagePrice) = apply { - cadence = newFloatingPackagePrice.cadence - currency = newFloatingPackagePrice.currency - itemId = newFloatingPackagePrice.itemId - modelType = newFloatingPackagePrice.modelType - name = newFloatingPackagePrice.name - packageConfig = newFloatingPackagePrice.packageConfig - billableMetricId = newFloatingPackagePrice.billableMetricId - billedInAdvance = newFloatingPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingPackagePrice.billingCycleConfiguration - conversionRate = newFloatingPackagePrice.conversionRate - externalPriceId = newFloatingPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingPackagePrice.invoicingCycleConfiguration - metadata = newFloatingPackagePrice.metadata - additionalProperties = - newFloatingPackagePrice.additionalProperties.toMutableMap() + internal fun from(package_: Package) = apply { + cadence = package_.cadence + currency = package_.currency + itemId = package_.itemId + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + metadata = package_.metadata + additionalProperties = package_.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -8323,18 +7277,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -8629,7 +7584,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingPackagePrice]. + * Returns an immutable instance of [Package]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -8638,19 +7593,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingPackagePrice = - NewFloatingPackagePrice( + fun build(): Package = + Package( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageConfig", packageConfig), billableMetricId, @@ -8668,7 +7622,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingPackagePrice = apply { + fun validate(): Package = apply { if (validated) { return@apply } @@ -8676,7 +7630,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageConfig().validate() billableMetricId() @@ -8710,7 +7668,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -8882,135 +7840,6 @@ private constructor( 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 PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * 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 { - PACKAGE, - /** - * 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) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - 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 PackageConfig private constructor( private val packageAmount: JsonField, @@ -10071,7 +8900,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Package && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -10081,16 +8910,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Package{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingMatrixPrice + class Matrix private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, private val matrixConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -10120,7 +8949,7 @@ private constructor( matrixConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -10207,11 +9036,15 @@ private constructor( fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -10347,16 +9180,6 @@ private constructor( @ExcludeMissing fun _matrixConfig(): JsonField = matrixConfig - /** - * 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]. * @@ -10472,8 +9295,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingMatrixPrice]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java @@ -10481,21 +9303,20 @@ private constructor( * .currency() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingMatrixPrice]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null private var itemId: JsonField? = null private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -10512,25 +9333,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingMatrixPrice: NewFloatingMatrixPrice) = apply { - cadence = newFloatingMatrixPrice.cadence - currency = newFloatingMatrixPrice.currency - itemId = newFloatingMatrixPrice.itemId - matrixConfig = newFloatingMatrixPrice.matrixConfig - modelType = newFloatingMatrixPrice.modelType - name = newFloatingMatrixPrice.name - billableMetricId = newFloatingMatrixPrice.billableMetricId - billedInAdvance = newFloatingMatrixPrice.billedInAdvance - billingCycleConfiguration = newFloatingMatrixPrice.billingCycleConfiguration - conversionRate = newFloatingMatrixPrice.conversionRate - externalPriceId = newFloatingMatrixPrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingMatrixPrice.invoicingCycleConfiguration - metadata = newFloatingMatrixPrice.metadata - additionalProperties = - newFloatingMatrixPrice.additionalProperties.toMutableMap() + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + currency = matrix.currency + itemId = matrix.itemId + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + metadata = matrix.metadata + additionalProperties = matrix.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -10583,18 +9402,19 @@ private constructor( this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -10875,7 +9695,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingMatrixPrice]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -10885,19 +9705,18 @@ private constructor( * .currency() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingMatrixPrice = - NewFloatingMatrixPrice( + fun build(): Matrix = + Matrix( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -10914,7 +9733,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingMatrixPrice = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -10923,7 +9742,11 @@ private constructor( currency() itemId() matrixConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -10957,7 +9780,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -11673,135 +10496,6 @@ private constructor( "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -12640,7 +11334,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Matrix && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -12650,16 +11344,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Matrix{cadence=$cadence, currency=$currency, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingMatrixWithAllocationPrice + class MatrixWithAllocation private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, private val matrixWithAllocationConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -12690,7 +11384,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -12778,11 +11472,15 @@ private constructor( matrixWithAllocationConfig.getRequired("matrix_with_allocation_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -12919,16 +11617,6 @@ private constructor( fun _matrixWithAllocationConfig(): JsonField = matrixWithAllocationConfig - /** - * 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]. * @@ -13045,7 +11733,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingMatrixWithAllocationPrice]. + * [MatrixWithAllocation]. * * The following fields are required: * ```java @@ -13053,14 +11741,13 @@ private constructor( * .currency() * .itemId() * .matrixWithAllocationConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingMatrixWithAllocationPrice]. */ + /** A builder for [MatrixWithAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -13068,7 +11755,7 @@ private constructor( private var itemId: JsonField? = null private var matrixWithAllocationConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -13085,29 +11772,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingMatrixWithAllocationPrice: NewFloatingMatrixWithAllocationPrice - ) = apply { - cadence = newFloatingMatrixWithAllocationPrice.cadence - currency = newFloatingMatrixWithAllocationPrice.currency - itemId = newFloatingMatrixWithAllocationPrice.itemId - matrixWithAllocationConfig = - newFloatingMatrixWithAllocationPrice.matrixWithAllocationConfig - modelType = newFloatingMatrixWithAllocationPrice.modelType - name = newFloatingMatrixWithAllocationPrice.name - billableMetricId = newFloatingMatrixWithAllocationPrice.billableMetricId - billedInAdvance = newFloatingMatrixWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingMatrixWithAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingMatrixWithAllocationPrice.conversionRate - externalPriceId = newFloatingMatrixWithAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingMatrixWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingMatrixWithAllocationPrice.invoiceGroupingKey + internal fun from(matrixWithAllocation: MatrixWithAllocation) = apply { + cadence = matrixWithAllocation.cadence + currency = matrixWithAllocation.currency + itemId = matrixWithAllocation.itemId + matrixWithAllocationConfig = matrixWithAllocation.matrixWithAllocationConfig + modelType = matrixWithAllocation.modelType + name = matrixWithAllocation.name + billableMetricId = matrixWithAllocation.billableMetricId + billedInAdvance = matrixWithAllocation.billedInAdvance + billingCycleConfiguration = matrixWithAllocation.billingCycleConfiguration + conversionRate = matrixWithAllocation.conversionRate + externalPriceId = matrixWithAllocation.externalPriceId + fixedPriceQuantity = matrixWithAllocation.fixedPriceQuantity + invoiceGroupingKey = matrixWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingMatrixWithAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingMatrixWithAllocationPrice.metadata + matrixWithAllocation.invoicingCycleConfiguration + metadata = matrixWithAllocation.metadata additionalProperties = - newFloatingMatrixWithAllocationPrice.additionalProperties.toMutableMap() + matrixWithAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -13162,18 +11845,19 @@ private constructor( matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -13454,7 +12138,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingMatrixWithAllocationPrice]. + * Returns an immutable instance of [MatrixWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -13464,19 +12148,18 @@ private constructor( * .currency() * .itemId() * .matrixWithAllocationConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingMatrixWithAllocationPrice = - NewFloatingMatrixWithAllocationPrice( + fun build(): MatrixWithAllocation = + MatrixWithAllocation( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), checkRequired("matrixWithAllocationConfig", matrixWithAllocationConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -13493,7 +12176,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingMatrixWithAllocationPrice = apply { + fun validate(): MatrixWithAllocation = apply { if (validated) { return@apply } @@ -13502,7 +12185,11 @@ private constructor( currency() itemId() matrixWithAllocationConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -13536,7 +12223,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixWithAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_allocation")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -14309,135 +12998,6 @@ private constructor( "MatrixWithAllocationConfig{allocation=$allocation, defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_ALLOCATION = of("matrix_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_ALLOCATION - } - - /** - * 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 { - MATRIX_WITH_ALLOCATION, - /** - * 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) { - MATRIX_WITH_ALLOCATION -> Value.MATRIX_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_ALLOCATION -> Known.MATRIX_WITH_ALLOCATION - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -15276,7 +13836,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithAllocation && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -15286,15 +13846,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MatrixWithAllocation{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredPrice + class Tiered private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredConfig: JsonField, private val billableMetricId: JsonField, @@ -15322,7 +13882,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -15405,11 +13965,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -15542,16 +14106,6 @@ private constructor( */ @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]. * @@ -15677,15 +14231,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredPrice]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` @@ -15693,13 +14245,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredPrice]. */ + /** A builder for [Tiered]. */ 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 modelType: JsonValue = JsonValue.from("tiered") private var name: JsonField? = null private var tieredConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -15717,25 +14269,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingTieredPrice: NewFloatingTieredPrice) = apply { - cadence = newFloatingTieredPrice.cadence - currency = newFloatingTieredPrice.currency - itemId = newFloatingTieredPrice.itemId - modelType = newFloatingTieredPrice.modelType - name = newFloatingTieredPrice.name - tieredConfig = newFloatingTieredPrice.tieredConfig - billableMetricId = newFloatingTieredPrice.billableMetricId - billedInAdvance = newFloatingTieredPrice.billedInAdvance - billingCycleConfiguration = newFloatingTieredPrice.billingCycleConfiguration - conversionRate = newFloatingTieredPrice.conversionRate - externalPriceId = newFloatingTieredPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredPrice.invoicingCycleConfiguration - metadata = newFloatingTieredPrice.metadata - additionalProperties = - newFloatingTieredPrice.additionalProperties.toMutableMap() + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + currency = tiered.currency + itemId = tiered.itemId + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + metadata = tiered.metadata + additionalProperties = tiered.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -15774,18 +14324,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -16080,7 +14631,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredPrice]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -16089,19 +14640,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredPrice = - NewFloatingTieredPrice( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredConfig", tieredConfig), billableMetricId, @@ -16119,7 +14669,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredPrice = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } @@ -16127,7 +14677,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredConfig().validate() billableMetricId() @@ -16161,7 +14715,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -16333,135 +14887,6 @@ private constructor( 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 = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * 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, - /** - * 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 -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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 -> Known.TIERED - 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 TieredConfig private constructor( private val tiers: JsonField>, @@ -17763,7 +16188,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tiered && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -17773,15 +16198,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredBpsPrice + class TieredBps private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredBpsConfig: JsonField, private val billableMetricId: JsonField, @@ -17809,7 +16234,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -17892,11 +16317,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -18030,16 +16459,6 @@ private constructor( */ @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]. * @@ -18165,15 +16584,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredBpsPrice]. + * Returns a mutable builder for constructing an instance of [TieredBps]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` @@ -18181,13 +16598,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredBpsPrice]. */ + /** A builder for [TieredBps]. */ 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 modelType: JsonValue = JsonValue.from("tiered_bps") private var name: JsonField? = null private var tieredBpsConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -18205,28 +16622,24 @@ private constructor( 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 - externalPriceId = newFloatingTieredBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredBpsPrice.invoicingCycleConfiguration - metadata = newFloatingTieredBpsPrice.metadata - additionalProperties = - newFloatingTieredBpsPrice.additionalProperties.toMutableMap() - } + internal fun from(tieredBps: TieredBps) = apply { + cadence = tieredBps.cadence + currency = tieredBps.currency + itemId = tieredBps.itemId + modelType = tieredBps.modelType + name = tieredBps.name + tieredBpsConfig = tieredBps.tieredBpsConfig + billableMetricId = tieredBps.billableMetricId + billedInAdvance = tieredBps.billedInAdvance + billingCycleConfiguration = tieredBps.billingCycleConfiguration + conversionRate = tieredBps.conversionRate + externalPriceId = tieredBps.externalPriceId + fixedPriceQuantity = tieredBps.fixedPriceQuantity + invoiceGroupingKey = tieredBps.invoiceGroupingKey + invoicingCycleConfiguration = tieredBps.invoicingCycleConfiguration + metadata = tieredBps.metadata + additionalProperties = tieredBps.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -18264,18 +16677,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -18570,7 +16984,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredBpsPrice]. + * Returns an immutable instance of [TieredBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -18579,19 +16993,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredBpsPrice = - NewFloatingTieredBpsPrice( + fun build(): TieredBps = + TieredBps( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredBpsConfig", tieredBpsConfig), billableMetricId, @@ -18609,7 +17022,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredBpsPrice = apply { + fun validate(): TieredBps = apply { if (validated) { return@apply } @@ -18617,7 +17030,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredBpsConfig().validate() billableMetricId() @@ -18651,7 +17068,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -18823,135 +17240,6 @@ private constructor( 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() - } - class TieredBpsConfig private constructor( private val tiers: JsonField>, @@ -20295,7 +18583,7 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBps && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -20305,16 +18593,16 @@ private constructor( 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, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredBps{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingBpsPrice + class Bps private constructor( private val bpsConfig: JsonField, private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -20344,7 +18632,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -20431,11 +18719,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -20571,16 +18863,6 @@ private constructor( */ @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]. * @@ -20696,8 +18978,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingBpsPrice]. + * Returns a mutable builder for constructing an instance of [Bps]. * * The following fields are required: * ```java @@ -20705,21 +18986,20 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingBpsPrice]. */ + /** A builder for [Bps]. */ 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 modelType: JsonValue = JsonValue.from("bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -20736,25 +19016,23 @@ private constructor( 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 - externalPriceId = newFloatingBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBpsPrice.metadata - additionalProperties = - newFloatingBpsPrice.additionalProperties.toMutableMap() + internal fun from(bps: Bps) = apply { + bpsConfig = bps.bpsConfig + cadence = bps.cadence + currency = bps.currency + itemId = bps.itemId + modelType = bps.modelType + name = bps.name + billableMetricId = bps.billableMetricId + billedInAdvance = bps.billedInAdvance + billingCycleConfiguration = bps.billingCycleConfiguration + conversionRate = bps.conversionRate + externalPriceId = bps.externalPriceId + fixedPriceQuantity = bps.fixedPriceQuantity + invoiceGroupingKey = bps.invoiceGroupingKey + invoicingCycleConfiguration = bps.invoicingCycleConfiguration + metadata = bps.metadata + additionalProperties = bps.additionalProperties.toMutableMap() } fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) @@ -20806,18 +19084,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -21098,7 +19377,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingBpsPrice]. + * Returns an immutable instance of [Bps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -21108,19 +19387,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingBpsPrice = - NewFloatingBpsPrice( + fun build(): Bps = + Bps( checkRequired("bpsConfig", bpsConfig), checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -21137,7 +19415,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingBpsPrice = apply { + fun validate(): Bps = apply { if (validated) { return@apply } @@ -21146,7 +19424,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -21180,7 +19462,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -21569,135 +19851,6 @@ private constructor( 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -22536,7 +20689,7 @@ private constructor( return true } - return /* spotless:off */ other is NewFloatingBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bps && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -22546,16 +20699,16 @@ private constructor( 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, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Bps{bpsConfig=$bpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingBulkBpsPrice + class BulkBps private constructor( private val bulkBpsConfig: JsonField, private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -22585,7 +20738,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -22672,11 +20825,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -22812,16 +20969,6 @@ private constructor( */ @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]. * @@ -22937,8 +21084,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of [BulkBps]. * * The following fields are required: * ```java @@ -22946,21 +21092,20 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingBulkBpsPrice]. */ + /** A builder for [BulkBps]. */ class Builder internal constructor() { private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -22977,26 +21122,23 @@ 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 - externalPriceId = newFloatingBulkBpsPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkBpsPrice.invoicingCycleConfiguration - metadata = newFloatingBulkBpsPrice.metadata - additionalProperties = - newFloatingBulkBpsPrice.additionalProperties.toMutableMap() + internal fun from(bulkBps: BulkBps) = apply { + bulkBpsConfig = bulkBps.bulkBpsConfig + cadence = bulkBps.cadence + currency = bulkBps.currency + itemId = bulkBps.itemId + modelType = bulkBps.modelType + name = bulkBps.name + billableMetricId = bulkBps.billableMetricId + billedInAdvance = bulkBps.billedInAdvance + billingCycleConfiguration = bulkBps.billingCycleConfiguration + conversionRate = bulkBps.conversionRate + externalPriceId = bulkBps.externalPriceId + fixedPriceQuantity = bulkBps.fixedPriceQuantity + invoiceGroupingKey = bulkBps.invoiceGroupingKey + invoicingCycleConfiguration = bulkBps.invoicingCycleConfiguration + metadata = bulkBps.metadata + additionalProperties = bulkBps.additionalProperties.toMutableMap() } fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = @@ -23049,18 +21191,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -23341,7 +21484,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingBulkBpsPrice]. + * Returns an immutable instance of [BulkBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -23351,19 +21494,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingBulkBpsPrice = - NewFloatingBulkBpsPrice( + fun build(): BulkBps = + BulkBps( checkRequired("bulkBpsConfig", bulkBpsConfig), checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -23380,7 +21522,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingBulkBpsPrice = apply { + fun validate(): BulkBps = apply { if (validated) { return@apply } @@ -23389,7 +21531,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -23423,7 +21569,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -24053,135 +22199,6 @@ private constructor( 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 BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -25020,7 +23037,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBps && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -25030,16 +23047,16 @@ private constructor( 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, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkBps{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingBulkPrice + class Bulk private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -25069,7 +23086,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -25156,11 +23173,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -25296,16 +23317,6 @@ private constructor( */ @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]. * @@ -25421,8 +23432,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingBulkPrice]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java @@ -25430,21 +23440,20 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingBulkPrice]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -25461,25 +23470,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newFloatingBulkPrice: NewFloatingBulkPrice) = apply { - bulkConfig = newFloatingBulkPrice.bulkConfig - cadence = newFloatingBulkPrice.cadence - currency = newFloatingBulkPrice.currency - itemId = newFloatingBulkPrice.itemId - modelType = newFloatingBulkPrice.modelType - name = newFloatingBulkPrice.name - billableMetricId = newFloatingBulkPrice.billableMetricId - billedInAdvance = newFloatingBulkPrice.billedInAdvance - billingCycleConfiguration = newFloatingBulkPrice.billingCycleConfiguration - conversionRate = newFloatingBulkPrice.conversionRate - externalPriceId = newFloatingBulkPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkPrice.invoicingCycleConfiguration - metadata = newFloatingBulkPrice.metadata - additionalProperties = - newFloatingBulkPrice.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + currency = bulk.currency + itemId = bulk.itemId + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + metadata = bulk.metadata + additionalProperties = bulk.additionalProperties.toMutableMap() } fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) @@ -25531,18 +23538,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -25823,7 +23831,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingBulkPrice]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -25833,19 +23841,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingBulkPrice = - NewFloatingBulkPrice( + fun build(): Bulk = + Bulk( checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -25862,7 +23869,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingBulkPrice = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -25871,7 +23878,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -25905,7 +23916,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -26493,135 +24504,6 @@ private constructor( 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 BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -27460,7 +25342,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bulk && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -27470,15 +25352,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingThresholdTotalAmountPrice + class ThresholdTotalAmount private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val thresholdTotalAmountConfig: JsonField, private val billableMetricId: JsonField, @@ -27506,7 +25388,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -27590,11 +25472,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -27728,16 +25614,6 @@ private constructor( */ @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]. * @@ -27865,14 +25741,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingThresholdTotalAmountPrice]. + * [ThresholdTotalAmount]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` @@ -27880,13 +25755,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingThresholdTotalAmountPrice]. */ + /** A builder for [ThresholdTotalAmount]. */ 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 modelType: JsonValue = JsonValue.from("threshold_total_amount") private var name: JsonField? = null private var thresholdTotalAmountConfig: JsonField? = null @@ -27905,29 +25780,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingThresholdTotalAmountPrice: NewFloatingThresholdTotalAmountPrice - ) = apply { - cadence = newFloatingThresholdTotalAmountPrice.cadence - currency = newFloatingThresholdTotalAmountPrice.currency - itemId = newFloatingThresholdTotalAmountPrice.itemId - modelType = newFloatingThresholdTotalAmountPrice.modelType - name = newFloatingThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newFloatingThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newFloatingThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newFloatingThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newFloatingThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newFloatingThresholdTotalAmountPrice.conversionRate - externalPriceId = newFloatingThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = newFloatingThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingThresholdTotalAmountPrice.invoiceGroupingKey + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + currency = thresholdTotalAmount.currency + itemId = thresholdTotalAmount.itemId + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newFloatingThresholdTotalAmountPrice.metadata + thresholdTotalAmount.invoicingCycleConfiguration + metadata = thresholdTotalAmount.metadata additionalProperties = - newFloatingThresholdTotalAmountPrice.additionalProperties.toMutableMap() + thresholdTotalAmount.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -27966,18 +25837,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -28274,7 +26146,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingThresholdTotalAmountPrice]. + * Returns an immutable instance of [ThresholdTotalAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -28283,19 +26155,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingThresholdTotalAmountPrice = - NewFloatingThresholdTotalAmountPrice( + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), billableMetricId, @@ -28313,7 +26184,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingThresholdTotalAmountPrice = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } @@ -28321,7 +26192,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -28355,7 +26230,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -28527,135 +26404,6 @@ private constructor( 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 THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * 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 { - THRESHOLD_TOTAL_AMOUNT, - /** - * 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) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - 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 ThresholdTotalAmountConfig @JsonCreator private constructor( @@ -29608,7 +27356,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmount && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -29618,15 +27366,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredPackagePrice + class TieredPackage private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredPackageConfig: JsonField, private val billableMetricId: JsonField, @@ -29654,7 +27402,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -29737,11 +27485,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -29875,16 +27627,6 @@ private constructor( */ @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]. * @@ -30010,15 +27752,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [TieredPackage]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` @@ -30026,13 +27766,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredPackagePrice]. */ + /** A builder for [TieredPackage]. */ 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 modelType: JsonValue = JsonValue.from("tiered_package") private var name: JsonField? = null private var tieredPackageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -30050,28 +27790,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingTieredPackagePrice: NewFloatingTieredPackagePrice - ) = apply { - cadence = newFloatingTieredPackagePrice.cadence - currency = newFloatingTieredPackagePrice.currency - itemId = newFloatingTieredPackagePrice.itemId - modelType = newFloatingTieredPackagePrice.modelType - name = newFloatingTieredPackagePrice.name - tieredPackageConfig = newFloatingTieredPackagePrice.tieredPackageConfig - billableMetricId = newFloatingTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingTieredPackagePrice.conversionRate - externalPriceId = newFloatingTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingTieredPackagePrice.metadata - additionalProperties = - newFloatingTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + currency = tieredPackage.currency + itemId = tieredPackage.itemId + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + metadata = tieredPackage.metadata + additionalProperties = tieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -30110,18 +27845,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -30417,7 +28153,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredPackagePrice]. + * Returns an immutable instance of [TieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -30426,19 +28162,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredPackagePrice = - NewFloatingTieredPackagePrice( + fun build(): TieredPackage = + TieredPackage( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredPackageConfig", tieredPackageConfig), billableMetricId, @@ -30456,7 +28191,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredPackagePrice = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } @@ -30464,7 +28199,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredPackageConfig().validate() billableMetricId() @@ -30498,7 +28237,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -30670,135 +28409,6 @@ private constructor( 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_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * 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_PACKAGE, - /** - * 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_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_PACKAGE -> Known.TIERED_PACKAGE - 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 TieredPackageConfig @JsonCreator private constructor( @@ -31750,7 +29360,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackage && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -31760,16 +29370,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredPackage{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedTieredPrice + class GroupedTiered private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedTieredConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -31799,7 +29409,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -31887,11 +29497,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -32027,16 +29641,6 @@ private constructor( */ @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]. * @@ -32152,8 +29756,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedTieredPrice]. + * Returns a mutable builder for constructing an instance of [GroupedTiered]. * * The following fields are required: * ```java @@ -32161,21 +29764,20 @@ private constructor( * .currency() * .groupedTieredConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedTieredPrice]. */ + /** A builder for [GroupedTiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null private var groupedTieredConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -32192,28 +29794,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingGroupedTieredPrice: NewFloatingGroupedTieredPrice - ) = apply { - cadence = newFloatingGroupedTieredPrice.cadence - currency = newFloatingGroupedTieredPrice.currency - groupedTieredConfig = newFloatingGroupedTieredPrice.groupedTieredConfig - itemId = newFloatingGroupedTieredPrice.itemId - modelType = newFloatingGroupedTieredPrice.modelType - name = newFloatingGroupedTieredPrice.name - billableMetricId = newFloatingGroupedTieredPrice.billableMetricId - billedInAdvance = newFloatingGroupedTieredPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedTieredPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedTieredPrice.conversionRate - externalPriceId = newFloatingGroupedTieredPrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedTieredPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedTieredPrice.metadata - additionalProperties = - newFloatingGroupedTieredPrice.additionalProperties.toMutableMap() + internal fun from(groupedTiered: GroupedTiered) = apply { + cadence = groupedTiered.cadence + currency = groupedTiered.currency + groupedTieredConfig = groupedTiered.groupedTieredConfig + itemId = groupedTiered.itemId + modelType = groupedTiered.modelType + name = groupedTiered.name + billableMetricId = groupedTiered.billableMetricId + billedInAdvance = groupedTiered.billedInAdvance + billingCycleConfiguration = groupedTiered.billingCycleConfiguration + conversionRate = groupedTiered.conversionRate + externalPriceId = groupedTiered.externalPriceId + fixedPriceQuantity = groupedTiered.fixedPriceQuantity + invoiceGroupingKey = groupedTiered.invoiceGroupingKey + invoicingCycleConfiguration = groupedTiered.invoicingCycleConfiguration + metadata = groupedTiered.metadata + additionalProperties = groupedTiered.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -32267,18 +29864,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -32559,7 +30157,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingGroupedTieredPrice]. + * Returns an immutable instance of [GroupedTiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -32569,19 +30167,18 @@ private constructor( * .currency() * .groupedTieredConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedTieredPrice = - NewFloatingGroupedTieredPrice( + fun build(): GroupedTiered = + GroupedTiered( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("groupedTieredConfig", groupedTieredConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -32598,7 +30195,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedTieredPrice = apply { + fun validate(): GroupedTiered = apply { if (validated) { return@apply } @@ -32607,7 +30204,11 @@ private constructor( currency() groupedTieredConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -32641,7 +30242,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedTieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -32925,135 +30526,6 @@ private constructor( "GroupedTieredConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED = of("grouped_tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED - } - - /** - * 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 { - GROUPED_TIERED, - /** - * 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) { - GROUPED_TIERED -> Value.GROUPED_TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED -> Known.GROUPED_TIERED - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -33892,7 +31364,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTiered && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -33902,16 +31374,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedTiered{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingMaxGroupTieredPackagePrice + class MaxGroupTieredPackage private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, private val maxGroupTieredPackageConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -33942,7 +31414,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -34030,11 +31502,15 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_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). + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -34171,16 +31647,6 @@ private constructor( fun _maxGroupTieredPackageConfig(): JsonField = maxGroupTieredPackageConfig - /** - * 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]. * @@ -34297,7 +31763,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingMaxGroupTieredPackagePrice]. + * [MaxGroupTieredPackage]. * * The following fields are required: * ```java @@ -34305,14 +31771,13 @@ private constructor( * .currency() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingMaxGroupTieredPackagePrice]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -34321,7 +31786,7 @@ private constructor( private var maxGroupTieredPackageConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -34338,32 +31803,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingMaxGroupTieredPackagePrice: NewFloatingMaxGroupTieredPackagePrice - ) = apply { - cadence = newFloatingMaxGroupTieredPackagePrice.cadence - currency = newFloatingMaxGroupTieredPackagePrice.currency - itemId = newFloatingMaxGroupTieredPackagePrice.itemId + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + currency = maxGroupTieredPackage.currency + itemId = maxGroupTieredPackage.itemId maxGroupTieredPackageConfig = - newFloatingMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newFloatingMaxGroupTieredPackagePrice.modelType - name = newFloatingMaxGroupTieredPackagePrice.name - billableMetricId = newFloatingMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingMaxGroupTieredPackagePrice.conversionRate - externalPriceId = newFloatingMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newFloatingMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingMaxGroupTieredPackagePrice.invoiceGroupingKey + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingMaxGroupTieredPackagePrice.metadata + maxGroupTieredPackage.invoicingCycleConfiguration + metadata = maxGroupTieredPackage.metadata additionalProperties = - newFloatingMaxGroupTieredPackagePrice.additionalProperties - .toMutableMap() + maxGroupTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -34418,18 +31877,19 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -34710,7 +32170,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingMaxGroupTieredPackagePrice]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -34720,14 +32180,13 @@ private constructor( * .currency() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingMaxGroupTieredPackagePrice = - NewFloatingMaxGroupTieredPackagePrice( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), @@ -34735,7 +32194,7 @@ private constructor( "maxGroupTieredPackageConfig", maxGroupTieredPackageConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -34752,7 +32211,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingMaxGroupTieredPackagePrice = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -34761,7 +32220,11 @@ private constructor( currency() itemId() maxGroupTieredPackageConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -34795,7 +32258,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -35081,135 +32546,6 @@ private constructor( "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * 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 { - MAX_GROUP_TIERED_PACKAGE, - /** - * 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) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -36048,7 +33384,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MaxGroupTieredPackage && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -36058,15 +33394,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMaxGroupTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{cadence=$cadence, currency=$currency, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredWithMinimumPrice + class TieredWithMinimum private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithMinimumConfig: JsonField, private val billableMetricId: JsonField, @@ -36094,7 +33430,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -36177,11 +33513,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -36315,16 +33655,6 @@ private constructor( */ @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]. * @@ -36452,14 +33782,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredWithMinimumPrice]. + * [TieredWithMinimum]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` @@ -36467,13 +33796,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredWithMinimumPrice]. */ + /** A builder for [TieredWithMinimum]. */ 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 modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var tieredWithMinimumConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -36491,29 +33820,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingTieredWithMinimumPrice: NewFloatingTieredWithMinimumPrice - ) = apply { - cadence = newFloatingTieredWithMinimumPrice.cadence - currency = newFloatingTieredWithMinimumPrice.currency - itemId = newFloatingTieredWithMinimumPrice.itemId - modelType = newFloatingTieredWithMinimumPrice.modelType - name = newFloatingTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newFloatingTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newFloatingTieredWithMinimumPrice.billableMetricId - billedInAdvance = newFloatingTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingTieredWithMinimumPrice.conversionRate - externalPriceId = newFloatingTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingTieredWithMinimumPrice.metadata - additionalProperties = - newFloatingTieredWithMinimumPrice.additionalProperties.toMutableMap() + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + currency = tieredWithMinimum.currency + itemId = tieredWithMinimum.itemId + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + metadata = tieredWithMinimum.metadata + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -36552,18 +33875,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -36858,7 +34182,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredWithMinimumPrice]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -36867,19 +34191,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredWithMinimumPrice = - NewFloatingTieredWithMinimumPrice( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), billableMetricId, @@ -36897,7 +34220,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredWithMinimumPrice = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } @@ -36905,7 +34228,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithMinimumConfig().validate() billableMetricId() @@ -36939,7 +34266,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -37111,135 +34440,6 @@ private constructor( 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_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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 TieredWithMinimumConfig @JsonCreator private constructor( @@ -38192,7 +35392,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithMinimum && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -38202,15 +35402,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredWithMinimum{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingPackageWithAllocationPrice + class PackageWithAllocation private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageWithAllocationConfig: JsonField, private val billableMetricId: JsonField, @@ -38238,7 +35438,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -38322,11 +35522,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -38460,16 +35664,6 @@ private constructor( */ @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]. * @@ -38597,14 +35791,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingPackageWithAllocationPrice]. + * [PackageWithAllocation]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` @@ -38612,13 +35805,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingPackageWithAllocationPrice]. */ + /** A builder for [PackageWithAllocation]. */ 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 modelType: JsonValue = JsonValue.from("package_with_allocation") private var name: JsonField? = null private var packageWithAllocationConfig: JsonField? = @@ -38638,32 +35831,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingPackageWithAllocationPrice: NewFloatingPackageWithAllocationPrice - ) = apply { - cadence = newFloatingPackageWithAllocationPrice.cadence - currency = newFloatingPackageWithAllocationPrice.currency - itemId = newFloatingPackageWithAllocationPrice.itemId - modelType = newFloatingPackageWithAllocationPrice.modelType - name = newFloatingPackageWithAllocationPrice.name + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + currency = packageWithAllocation.currency + itemId = packageWithAllocation.itemId + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name packageWithAllocationConfig = - newFloatingPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = newFloatingPackageWithAllocationPrice.billableMetricId - billedInAdvance = newFloatingPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingPackageWithAllocationPrice.conversionRate - externalPriceId = newFloatingPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newFloatingPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingPackageWithAllocationPrice.invoiceGroupingKey + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingPackageWithAllocationPrice.metadata + packageWithAllocation.invoicingCycleConfiguration + metadata = packageWithAllocation.metadata additionalProperties = - newFloatingPackageWithAllocationPrice.additionalProperties - .toMutableMap() + packageWithAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -38702,18 +35889,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -39010,7 +36198,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingPackageWithAllocationPrice]. + * Returns an immutable instance of [PackageWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -39019,19 +36207,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingPackageWithAllocationPrice = - NewFloatingPackageWithAllocationPrice( + fun build(): PackageWithAllocation = + PackageWithAllocation( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "packageWithAllocationConfig", @@ -39052,7 +36239,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingPackageWithAllocationPrice = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } @@ -39060,7 +36247,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageWithAllocationConfig().validate() billableMetricId() @@ -39094,7 +36285,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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 (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -39266,135 +36459,6 @@ private constructor( 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 PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * 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 { - PACKAGE_WITH_ALLOCATION, - /** - * 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) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - 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 PackageWithAllocationConfig @JsonCreator private constructor( @@ -40348,7 +37412,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocation && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -40358,15 +37422,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "PackageWithAllocation{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredPackageWithMinimumPrice + class TieredPackageWithMinimum private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredPackageWithMinimumConfig: JsonField, @@ -40395,7 +37459,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -40479,11 +37543,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -40617,16 +37685,6 @@ private constructor( */ @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]. * @@ -40754,14 +37812,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredPackageWithMinimumPrice]. + * [TieredPackageWithMinimum]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredPackageWithMinimumConfig() * ``` @@ -40769,13 +37826,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredPackageWithMinimumPrice]. */ + /** A builder for [TieredPackageWithMinimum]. */ 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 modelType: JsonValue = JsonValue.from("tiered_package_with_minimum") private var name: JsonField? = null private var tieredPackageWithMinimumConfig: JsonField? = @@ -40795,33 +37852,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingTieredPackageWithMinimumPrice: - NewFloatingTieredPackageWithMinimumPrice - ) = apply { - cadence = newFloatingTieredPackageWithMinimumPrice.cadence - currency = newFloatingTieredPackageWithMinimumPrice.currency - itemId = newFloatingTieredPackageWithMinimumPrice.itemId - modelType = newFloatingTieredPackageWithMinimumPrice.modelType - name = newFloatingTieredPackageWithMinimumPrice.name + internal fun from(tieredPackageWithMinimum: TieredPackageWithMinimum) = apply { + cadence = tieredPackageWithMinimum.cadence + currency = tieredPackageWithMinimum.currency + itemId = tieredPackageWithMinimum.itemId + modelType = tieredPackageWithMinimum.modelType + name = tieredPackageWithMinimum.name tieredPackageWithMinimumConfig = - newFloatingTieredPackageWithMinimumPrice.tieredPackageWithMinimumConfig - billableMetricId = newFloatingTieredPackageWithMinimumPrice.billableMetricId - billedInAdvance = newFloatingTieredPackageWithMinimumPrice.billedInAdvance + tieredPackageWithMinimum.tieredPackageWithMinimumConfig + billableMetricId = tieredPackageWithMinimum.billableMetricId + billedInAdvance = tieredPackageWithMinimum.billedInAdvance billingCycleConfiguration = - newFloatingTieredPackageWithMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingTieredPackageWithMinimumPrice.conversionRate - externalPriceId = newFloatingTieredPackageWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingTieredPackageWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingTieredPackageWithMinimumPrice.invoiceGroupingKey + tieredPackageWithMinimum.billingCycleConfiguration + conversionRate = tieredPackageWithMinimum.conversionRate + externalPriceId = tieredPackageWithMinimum.externalPriceId + fixedPriceQuantity = tieredPackageWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredPackageWithMinimum.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingTieredPackageWithMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingTieredPackageWithMinimumPrice.metadata + tieredPackageWithMinimum.invoicingCycleConfiguration + metadata = tieredPackageWithMinimum.metadata additionalProperties = - newFloatingTieredPackageWithMinimumPrice.additionalProperties - .toMutableMap() + tieredPackageWithMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -40860,18 +37911,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -41170,7 +38222,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredPackageWithMinimumPrice]. + * Returns an immutable instance of [TieredPackageWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -41179,19 +38231,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredPackageWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredPackageWithMinimumPrice = - NewFloatingTieredPackageWithMinimumPrice( + fun build(): TieredPackageWithMinimum = + TieredPackageWithMinimum( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "tieredPackageWithMinimumConfig", @@ -41212,7 +38263,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredPackageWithMinimumPrice = apply { + fun validate(): TieredPackageWithMinimum = apply { if (validated) { return@apply } @@ -41220,7 +38271,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredPackageWithMinimumConfig().validate() billableMetricId() @@ -41254,7 +38309,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_package_with_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (tieredPackageWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -41426,136 +38483,6 @@ private constructor( 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_PACKAGE_WITH_MINIMUM = of("tiered_package_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_PACKAGE_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Value.TIERED_PACKAGE_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE_WITH_MINIMUM -> Known.TIERED_PACKAGE_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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 TieredPackageWithMinimumConfig @JsonCreator private constructor( @@ -42509,7 +39436,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackageWithMinimum && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -42519,15 +39446,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredPackageWithMinimum{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingUnitWithPercentPrice + class UnitWithPercent private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithPercentConfig: JsonField, private val billableMetricId: JsonField, @@ -42555,7 +39482,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -42638,11 +39565,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -42776,16 +39707,6 @@ private constructor( */ @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]. * @@ -42912,15 +39833,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewFloatingUnitWithPercentPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` @@ -42928,13 +39847,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingUnitWithPercentPrice]. */ + /** A builder for [UnitWithPercent]. */ 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 modelType: JsonValue = JsonValue.from("unit_with_percent") private var name: JsonField? = null private var unitWithPercentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -42952,29 +39871,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingUnitWithPercentPrice: NewFloatingUnitWithPercentPrice - ) = apply { - cadence = newFloatingUnitWithPercentPrice.cadence - currency = newFloatingUnitWithPercentPrice.currency - itemId = newFloatingUnitWithPercentPrice.itemId - modelType = newFloatingUnitWithPercentPrice.modelType - name = newFloatingUnitWithPercentPrice.name - unitWithPercentConfig = - newFloatingUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newFloatingUnitWithPercentPrice.billableMetricId - billedInAdvance = newFloatingUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newFloatingUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newFloatingUnitWithPercentPrice.conversionRate - externalPriceId = newFloatingUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newFloatingUnitWithPercentPrice.metadata - additionalProperties = - newFloatingUnitWithPercentPrice.additionalProperties.toMutableMap() + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + currency = unitWithPercent.currency + itemId = unitWithPercent.itemId + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + metadata = unitWithPercent.metadata + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -43013,18 +39926,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -43319,7 +40233,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingUnitWithPercentPrice]. + * Returns an immutable instance of [UnitWithPercent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -43328,19 +40242,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingUnitWithPercentPrice = - NewFloatingUnitWithPercentPrice( + fun build(): UnitWithPercent = + UnitWithPercent( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithPercentConfig", unitWithPercentConfig), billableMetricId, @@ -43358,7 +40271,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingUnitWithPercentPrice = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } @@ -43366,7 +40279,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithPercentConfig().validate() billableMetricId() @@ -43400,7 +40317,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -43572,135 +40489,6 @@ private constructor( 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 UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * 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 { - UNIT_WITH_PERCENT, - /** - * 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) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - 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 UnitWithPercentConfig @JsonCreator private constructor( @@ -44652,7 +41440,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercent && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -44662,15 +41450,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "UnitWithPercent{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingTieredWithProrationPrice + class TieredWithProration private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -44698,7 +41486,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -44782,11 +41570,15 @@ private constructor( 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). + * 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). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -44920,16 +41712,6 @@ private constructor( */ @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]. * @@ -45057,14 +41839,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingTieredWithProrationPrice]. + * [TieredWithProration]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` @@ -45072,13 +41853,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingTieredWithProrationPrice]. */ + /** A builder for [TieredWithProration]. */ 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 modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null private var tieredWithProrationConfig: JsonField? = null @@ -45097,29 +41878,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingTieredWithProrationPrice: NewFloatingTieredWithProrationPrice - ) = apply { - cadence = newFloatingTieredWithProrationPrice.cadence - currency = newFloatingTieredWithProrationPrice.currency - itemId = newFloatingTieredWithProrationPrice.itemId - modelType = newFloatingTieredWithProrationPrice.modelType - name = newFloatingTieredWithProrationPrice.name - tieredWithProrationConfig = - newFloatingTieredWithProrationPrice.tieredWithProrationConfig - billableMetricId = newFloatingTieredWithProrationPrice.billableMetricId - billedInAdvance = newFloatingTieredWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingTieredWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingTieredWithProrationPrice.conversionRate - externalPriceId = newFloatingTieredWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingTieredWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingTieredWithProrationPrice.invoiceGroupingKey + internal fun from(tieredWithProration: TieredWithProration) = apply { + cadence = tieredWithProration.cadence + currency = tieredWithProration.currency + itemId = tieredWithProration.itemId + modelType = tieredWithProration.modelType + name = tieredWithProration.name + tieredWithProrationConfig = tieredWithProration.tieredWithProrationConfig + billableMetricId = tieredWithProration.billableMetricId + billedInAdvance = tieredWithProration.billedInAdvance + billingCycleConfiguration = tieredWithProration.billingCycleConfiguration + conversionRate = tieredWithProration.conversionRate + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingTieredWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingTieredWithProrationPrice.metadata + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata additionalProperties = - newFloatingTieredWithProrationPrice.additionalProperties.toMutableMap() + tieredWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -45158,18 +41935,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -45465,7 +42243,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingTieredWithProrationPrice]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -45474,19 +42252,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingTieredWithProrationPrice = - NewFloatingTieredWithProrationPrice( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, @@ -45504,7 +42281,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingTieredWithProrationPrice = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } @@ -45512,7 +42289,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithProrationConfig().validate() billableMetricId() @@ -45546,7 +42327,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -45718,135 +42501,6 @@ private constructor( 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( @@ -46799,7 +43453,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithProration && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -46809,15 +43463,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingUnitWithProrationPrice + class UnitWithProration private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -46845,7 +43499,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -46928,11 +43582,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -47066,16 +43724,6 @@ private constructor( */ @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]. * @@ -47203,14 +43851,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingUnitWithProrationPrice]. + * [UnitWithProration]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` @@ -47218,13 +43865,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingUnitWithProrationPrice]. */ + /** A builder for [UnitWithProration]. */ 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 modelType: JsonValue = JsonValue.from("unit_with_proration") private var name: JsonField? = null private var unitWithProrationConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -47242,29 +43889,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingUnitWithProrationPrice: NewFloatingUnitWithProrationPrice - ) = apply { - cadence = newFloatingUnitWithProrationPrice.cadence - currency = newFloatingUnitWithProrationPrice.currency - itemId = newFloatingUnitWithProrationPrice.itemId - modelType = newFloatingUnitWithProrationPrice.modelType - name = newFloatingUnitWithProrationPrice.name - unitWithProrationConfig = - newFloatingUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newFloatingUnitWithProrationPrice.billableMetricId - billedInAdvance = newFloatingUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingUnitWithProrationPrice.conversionRate - externalPriceId = newFloatingUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingUnitWithProrationPrice.metadata - additionalProperties = - newFloatingUnitWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + currency = unitWithProration.currency + itemId = unitWithProration.itemId + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + metadata = unitWithProration.metadata + additionalProperties = unitWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -47303,18 +43944,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -47609,7 +44251,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingUnitWithProrationPrice]. + * Returns an immutable instance of [UnitWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -47618,19 +44260,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingUnitWithProrationPrice = - NewFloatingUnitWithProrationPrice( + fun build(): UnitWithProration = + UnitWithProration( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithProrationConfig", unitWithProrationConfig), billableMetricId, @@ -47648,7 +44289,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingUnitWithProrationPrice = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } @@ -47656,7 +44297,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithProrationConfig().validate() billableMetricId() @@ -47690,7 +44335,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -47862,135 +44509,6 @@ private constructor( 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 UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_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 { - UNIT_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) { - UNIT_WITH_PRORATION -> Value.UNIT_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) { - UNIT_WITH_PRORATION -> Known.UNIT_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 UnitWithProrationConfig @JsonCreator private constructor( @@ -48943,7 +45461,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProration && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -48953,16 +45471,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "UnitWithProration{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedAllocationPrice + class GroupedAllocation private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedAllocationConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -48992,7 +45510,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -49080,11 +45598,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -49221,16 +45743,6 @@ private constructor( */ @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]. * @@ -49347,7 +45859,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedAllocationPrice]. + * [GroupedAllocation]. * * The following fields are required: * ```java @@ -49355,21 +45867,20 @@ private constructor( * .currency() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedAllocationPrice]. */ + /** A builder for [GroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var currency: JsonField? = null private var groupedAllocationConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -49386,29 +45897,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingGroupedAllocationPrice: NewFloatingGroupedAllocationPrice - ) = apply { - cadence = newFloatingGroupedAllocationPrice.cadence - currency = newFloatingGroupedAllocationPrice.currency - groupedAllocationConfig = - newFloatingGroupedAllocationPrice.groupedAllocationConfig - itemId = newFloatingGroupedAllocationPrice.itemId - modelType = newFloatingGroupedAllocationPrice.modelType - name = newFloatingGroupedAllocationPrice.name - billableMetricId = newFloatingGroupedAllocationPrice.billableMetricId - billedInAdvance = newFloatingGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedAllocationPrice.conversionRate - externalPriceId = newFloatingGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedAllocationPrice.metadata - additionalProperties = - newFloatingGroupedAllocationPrice.additionalProperties.toMutableMap() + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + currency = groupedAllocation.currency + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + metadata = groupedAllocation.metadata + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -49461,18 +45966,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -49753,7 +46259,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingGroupedAllocationPrice]. + * Returns an immutable instance of [GroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -49763,19 +46269,18 @@ private constructor( * .currency() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedAllocationPrice = - NewFloatingGroupedAllocationPrice( + fun build(): GroupedAllocation = + GroupedAllocation( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("groupedAllocationConfig", groupedAllocationConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -49792,7 +46297,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedAllocationPrice = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -49801,7 +46306,11 @@ private constructor( currency() groupedAllocationConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -49835,7 +46344,7 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -50120,135 +46629,6 @@ private constructor( "GroupedAllocationConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * 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 { - GROUPED_ALLOCATION, - /** - * 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) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -51087,7 +47467,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocation && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -51097,17 +47477,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedAllocation{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedWithProratedMinimumPrice + class GroupedWithProratedMinimum private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedWithProratedMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -51138,7 +47518,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -51228,11 +47608,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -51369,16 +47753,6 @@ private constructor( */ @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]. * @@ -51495,7 +47869,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedWithProratedMinimumPrice]. + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```java @@ -51503,14 +47877,13 @@ private constructor( * .currency() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedWithProratedMinimumPrice]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -51519,7 +47892,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -51536,36 +47910,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingGroupedWithProratedMinimumPrice: - NewFloatingGroupedWithProratedMinimumPrice - ) = apply { - cadence = newFloatingGroupedWithProratedMinimumPrice.cadence - currency = newFloatingGroupedWithProratedMinimumPrice.currency - groupedWithProratedMinimumConfig = - newFloatingGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newFloatingGroupedWithProratedMinimumPrice.itemId - modelType = newFloatingGroupedWithProratedMinimumPrice.modelType - name = newFloatingGroupedWithProratedMinimumPrice.name - billableMetricId = - newFloatingGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = newFloatingGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedWithProratedMinimumPrice.conversionRate - externalPriceId = newFloatingGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedWithProratedMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedWithProratedMinimumPrice.metadata - additionalProperties = - newFloatingGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + currency = groupedWithProratedMinimum.currency + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + metadata = groupedWithProratedMinimum.metadata + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -51625,18 +47992,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -51917,8 +48285,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewFloatingGroupedWithProratedMinimumPrice]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -51928,14 +48295,13 @@ private constructor( * .currency() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedWithProratedMinimumPrice = - NewFloatingGroupedWithProratedMinimumPrice( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired( @@ -51943,7 +48309,7 @@ private constructor( groupedWithProratedMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -51960,7 +48326,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedWithProratedMinimumPrice = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -51969,7 +48335,11 @@ private constructor( currency() groupedWithProratedMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -52003,7 +48373,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -52289,136 +48661,6 @@ private constructor( "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -53257,7 +49499,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimum && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -53267,17 +49509,17 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedWithMeteredMinimumPrice + class GroupedWithMeteredMinimum private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -53308,7 +49550,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -53398,11 +49640,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -53539,16 +49785,6 @@ private constructor( */ @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]. * @@ -53665,7 +49901,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedWithMeteredMinimumPrice]. + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```java @@ -53673,14 +49909,13 @@ private constructor( * .currency() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedWithMeteredMinimumPrice]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -53689,7 +49924,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -53706,36 +49942,29 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingGroupedWithMeteredMinimumPrice: - NewFloatingGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newFloatingGroupedWithMeteredMinimumPrice.cadence - currency = newFloatingGroupedWithMeteredMinimumPrice.currency - groupedWithMeteredMinimumConfig = - newFloatingGroupedWithMeteredMinimumPrice - .groupedWithMeteredMinimumConfig - itemId = newFloatingGroupedWithMeteredMinimumPrice.itemId - modelType = newFloatingGroupedWithMeteredMinimumPrice.modelType - name = newFloatingGroupedWithMeteredMinimumPrice.name - billableMetricId = - newFloatingGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = newFloatingGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = newFloatingGroupedWithMeteredMinimumPrice.conversionRate - externalPriceId = newFloatingGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = - newFloatingGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingGroupedWithMeteredMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingGroupedWithMeteredMinimumPrice.invoicingCycleConfiguration - metadata = newFloatingGroupedWithMeteredMinimumPrice.metadata - additionalProperties = - newFloatingGroupedWithMeteredMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + currency = groupedWithMeteredMinimum.currency + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + metadata = groupedWithMeteredMinimum.metadata + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -53794,18 +50023,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -54086,7 +50316,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingGroupedWithMeteredMinimumPrice]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -54096,14 +50326,13 @@ private constructor( * .currency() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedWithMeteredMinimumPrice = - NewFloatingGroupedWithMeteredMinimumPrice( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired( @@ -54111,7 +50340,7 @@ private constructor( groupedWithMeteredMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -54128,7 +50357,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedWithMeteredMinimumPrice = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -54137,7 +50366,11 @@ private constructor( currency() groupedWithMeteredMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -54171,7 +50404,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -54457,136 +50692,6 @@ private constructor( "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -55425,7 +51530,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimum && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -55435,16 +51540,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingMatrixWithDisplayNamePrice + class MatrixWithDisplayName private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, private val matrixWithDisplayNameConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -55475,7 +51580,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -55563,11 +51668,15 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -55704,16 +51813,6 @@ private constructor( fun _matrixWithDisplayNameConfig(): JsonField = matrixWithDisplayNameConfig - /** - * 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]. * @@ -55830,7 +51929,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingMatrixWithDisplayNamePrice]. + * [MatrixWithDisplayName]. * * The following fields are required: * ```java @@ -55838,14 +51937,13 @@ private constructor( * .currency() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingMatrixWithDisplayNamePrice]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -55854,7 +51952,7 @@ private constructor( private var matrixWithDisplayNameConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -55871,32 +51969,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingMatrixWithDisplayNamePrice: NewFloatingMatrixWithDisplayNamePrice - ) = apply { - cadence = newFloatingMatrixWithDisplayNamePrice.cadence - currency = newFloatingMatrixWithDisplayNamePrice.currency - itemId = newFloatingMatrixWithDisplayNamePrice.itemId + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + currency = matrixWithDisplayName.currency + itemId = matrixWithDisplayName.itemId matrixWithDisplayNameConfig = - newFloatingMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newFloatingMatrixWithDisplayNamePrice.modelType - name = newFloatingMatrixWithDisplayNamePrice.name - billableMetricId = newFloatingMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newFloatingMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newFloatingMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newFloatingMatrixWithDisplayNamePrice.conversionRate - externalPriceId = newFloatingMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = - newFloatingMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingMatrixWithDisplayNamePrice.invoiceGroupingKey + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newFloatingMatrixWithDisplayNamePrice.metadata + matrixWithDisplayName.invoicingCycleConfiguration + metadata = matrixWithDisplayName.metadata additionalProperties = - newFloatingMatrixWithDisplayNamePrice.additionalProperties - .toMutableMap() + matrixWithDisplayName.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -55951,18 +52043,19 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -56243,7 +52336,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingMatrixWithDisplayNamePrice]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -56253,14 +52346,13 @@ private constructor( * .currency() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingMatrixWithDisplayNamePrice = - NewFloatingMatrixWithDisplayNamePrice( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), @@ -56268,7 +52360,7 @@ private constructor( "matrixWithDisplayNameConfig", matrixWithDisplayNameConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -56285,7 +52377,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingMatrixWithDisplayNamePrice = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -56294,7 +52386,11 @@ private constructor( currency() itemId() matrixWithDisplayNameConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -56328,7 +52424,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -56614,135 +52712,6 @@ private constructor( "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * 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 { - MATRIX_WITH_DISPLAY_NAME, - /** - * 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) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -57581,7 +53550,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayName && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -57591,16 +53560,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingMatrixWithDisplayNamePrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingBulkWithProrationPrice + class BulkWithProration private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -57630,7 +53599,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -57718,11 +53687,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -57859,16 +53832,6 @@ private constructor( */ @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]. * @@ -57985,7 +53948,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingBulkWithProrationPrice]. + * [BulkWithProration]. * * The following fields are required: * ```java @@ -57993,21 +53956,20 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingBulkWithProrationPrice]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -58024,29 +53986,23 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingBulkWithProrationPrice: NewFloatingBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newFloatingBulkWithProrationPrice.bulkWithProrationConfig - cadence = newFloatingBulkWithProrationPrice.cadence - currency = newFloatingBulkWithProrationPrice.currency - itemId = newFloatingBulkWithProrationPrice.itemId - modelType = newFloatingBulkWithProrationPrice.modelType - name = newFloatingBulkWithProrationPrice.name - billableMetricId = newFloatingBulkWithProrationPrice.billableMetricId - billedInAdvance = newFloatingBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newFloatingBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newFloatingBulkWithProrationPrice.conversionRate - externalPriceId = newFloatingBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = newFloatingBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newFloatingBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newFloatingBulkWithProrationPrice.metadata - additionalProperties = - newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + currency = bulkWithProration.currency + itemId = bulkWithProration.itemId + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + metadata = bulkWithProration.metadata + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = @@ -58099,18 +54055,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -58391,7 +54348,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingBulkWithProrationPrice]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -58401,19 +54358,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingBulkWithProrationPrice = - NewFloatingBulkWithProrationPrice( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -58430,7 +54386,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingBulkWithProrationPrice = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -58439,7 +54395,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -58473,7 +54433,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -58758,135 +54720,6 @@ private constructor( 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 BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_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 { - BULK_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) { - BULK_WITH_PRORATION -> Value.BULK_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) { - BULK_WITH_PRORATION -> Known.BULK_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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -59725,7 +55558,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkWithProration && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -59735,16 +55568,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingGroupedTieredPackagePrice + class GroupedTieredPackage private constructor( private val cadence: JsonField, private val currency: JsonField, private val groupedTieredPackageConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -59775,7 +55608,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -59863,11 +55696,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -60004,16 +55841,6 @@ private constructor( */ @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]. * @@ -60130,7 +55957,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingGroupedTieredPackagePrice]. + * [GroupedTieredPackage]. * * The following fields are required: * ```java @@ -60138,14 +55965,13 @@ private constructor( * .currency() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingGroupedTieredPackagePrice]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -60153,7 +55979,7 @@ private constructor( private var groupedTieredPackageConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -60170,29 +55996,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingGroupedTieredPackagePrice: NewFloatingGroupedTieredPackagePrice - ) = apply { - cadence = newFloatingGroupedTieredPackagePrice.cadence - currency = newFloatingGroupedTieredPackagePrice.currency - groupedTieredPackageConfig = - newFloatingGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newFloatingGroupedTieredPackagePrice.itemId - modelType = newFloatingGroupedTieredPackagePrice.modelType - name = newFloatingGroupedTieredPackagePrice.name - billableMetricId = newFloatingGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newFloatingGroupedTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newFloatingGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newFloatingGroupedTieredPackagePrice.conversionRate - externalPriceId = newFloatingGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = newFloatingGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newFloatingGroupedTieredPackagePrice.invoiceGroupingKey + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + currency = groupedTieredPackage.currency + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newFloatingGroupedTieredPackagePrice.metadata + groupedTieredPackage.invoicingCycleConfiguration + metadata = groupedTieredPackage.metadata additionalProperties = - newFloatingGroupedTieredPackagePrice.additionalProperties.toMutableMap() + groupedTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -60247,18 +56069,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -60539,7 +56362,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingGroupedTieredPackagePrice]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -60549,19 +56372,18 @@ private constructor( * .currency() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingGroupedTieredPackagePrice = - NewFloatingGroupedTieredPackagePrice( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -60578,7 +56400,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingGroupedTieredPackagePrice = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -60587,7 +56409,11 @@ private constructor( currency() groupedTieredPackageConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -60621,7 +56447,9 @@ private constructor( (if (currency.asKnown().isPresent) 1 else 0) + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -60906,135 +56734,6 @@ private constructor( "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * 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 { - GROUPED_TIERED_PACKAGE, - /** - * 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) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -61873,7 +57572,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPackage && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -61883,15 +57582,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingGroupedTieredPackagePrice{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{cadence=$cadence, currency=$currency, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingScalableMatrixWithUnitPricingPrice + class ScalableMatrixWithUnitPricing private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithUnitPricingConfig: JsonField, @@ -61920,7 +57619,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -62005,11 +57704,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -62145,16 +57848,6 @@ private constructor( */ @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]. * @@ -62283,14 +57976,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingScalableMatrixWithUnitPricingPrice]. + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` @@ -62298,13 +57990,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ 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 modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var scalableMatrixWithUnitPricingConfig: JsonField? = @@ -62325,38 +58018,28 @@ private constructor( @JvmSynthetic internal fun from( - newFloatingScalableMatrixWithUnitPricingPrice: - NewFloatingScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = apply { - cadence = newFloatingScalableMatrixWithUnitPricingPrice.cadence - currency = newFloatingScalableMatrixWithUnitPricingPrice.currency - itemId = newFloatingScalableMatrixWithUnitPricingPrice.itemId - modelType = newFloatingScalableMatrixWithUnitPricingPrice.modelType - name = newFloatingScalableMatrixWithUnitPricingPrice.name + cadence = scalableMatrixWithUnitPricing.cadence + currency = scalableMatrixWithUnitPricing.currency + itemId = scalableMatrixWithUnitPricing.itemId + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name scalableMatrixWithUnitPricingConfig = - newFloatingScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = - newFloatingScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = - newFloatingScalableMatrixWithUnitPricingPrice.billedInAdvance + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance billingCycleConfiguration = - newFloatingScalableMatrixWithUnitPricingPrice.billingCycleConfiguration - conversionRate = - newFloatingScalableMatrixWithUnitPricingPrice.conversionRate - externalPriceId = - newFloatingScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newFloatingScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingScalableMatrixWithUnitPricingPrice.invoiceGroupingKey + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingScalableMatrixWithUnitPricingPrice - .invoicingCycleConfiguration - metadata = newFloatingScalableMatrixWithUnitPricingPrice.metadata + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithUnitPricing.metadata additionalProperties = - newFloatingScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -62395,18 +58078,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -62711,8 +58395,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewFloatingScalableMatrixWithUnitPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -62721,19 +58404,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingScalableMatrixWithUnitPricingPrice = - NewFloatingScalableMatrixWithUnitPricingPrice( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithUnitPricingConfig", @@ -62754,7 +58436,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingScalableMatrixWithUnitPricingPrice = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } @@ -62762,7 +58444,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -62796,7 +58482,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -62969,139 +58657,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_UNIT_PRICING = - of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - 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 ScalableMatrixWithUnitPricingConfig @JsonCreator private constructor( @@ -64056,7 +59611,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithUnitPricing && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -64066,15 +59621,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingScalableMatrixWithUnitPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingScalableMatrixWithTieredPricingPrice + class ScalableMatrixWithTieredPricing private constructor( private val cadence: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithTieredPricingConfig: JsonField, @@ -64103,7 +59658,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -64188,11 +59743,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -64328,16 +59887,6 @@ private constructor( */ @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]. * @@ -64466,14 +60015,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingScalableMatrixWithTieredPricingPrice]. + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` @@ -64481,13 +60029,14 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingScalableMatrixWithTieredPricingPrice]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ 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 modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var scalableMatrixWithTieredPricingConfig: JsonField? = @@ -64508,39 +60057,28 @@ private constructor( @JvmSynthetic internal fun from( - newFloatingScalableMatrixWithTieredPricingPrice: - NewFloatingScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = apply { - cadence = newFloatingScalableMatrixWithTieredPricingPrice.cadence - currency = newFloatingScalableMatrixWithTieredPricingPrice.currency - itemId = newFloatingScalableMatrixWithTieredPricingPrice.itemId - modelType = newFloatingScalableMatrixWithTieredPricingPrice.modelType - name = newFloatingScalableMatrixWithTieredPricingPrice.name + cadence = scalableMatrixWithTieredPricing.cadence + currency = scalableMatrixWithTieredPricing.currency + itemId = scalableMatrixWithTieredPricing.itemId + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name scalableMatrixWithTieredPricingConfig = - newFloatingScalableMatrixWithTieredPricingPrice - .scalableMatrixWithTieredPricingConfig - billableMetricId = - newFloatingScalableMatrixWithTieredPricingPrice.billableMetricId - billedInAdvance = - newFloatingScalableMatrixWithTieredPricingPrice.billedInAdvance + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance billingCycleConfiguration = - newFloatingScalableMatrixWithTieredPricingPrice - .billingCycleConfiguration - conversionRate = - newFloatingScalableMatrixWithTieredPricingPrice.conversionRate - externalPriceId = - newFloatingScalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = - newFloatingScalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingScalableMatrixWithTieredPricingPrice.invoiceGroupingKey + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingScalableMatrixWithTieredPricingPrice - .invoicingCycleConfiguration - metadata = newFloatingScalableMatrixWithTieredPricingPrice.metadata + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithTieredPricing.metadata additionalProperties = - newFloatingScalableMatrixWithTieredPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -64579,18 +60117,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -64895,8 +60434,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewFloatingScalableMatrixWithTieredPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -64905,19 +60443,18 @@ private constructor( * .cadence() * .currency() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingScalableMatrixWithTieredPricingPrice = - NewFloatingScalableMatrixWithTieredPricingPrice( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("cadence", cadence), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithTieredPricingConfig", @@ -64938,7 +60475,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingScalableMatrixWithTieredPricingPrice = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } @@ -64946,7 +60483,11 @@ private constructor( cadence().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -64980,7 +60521,10 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -65153,139 +60697,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - 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 ScalableMatrixWithTieredPricingConfig @JsonCreator private constructor( @@ -66243,7 +61654,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithTieredPricing && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -66253,16 +61664,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingScalableMatrixWithTieredPricingPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - class NewFloatingCumulativeGroupedBulkPrice + class CumulativeGroupedBulk private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, private val currency: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -66293,7 +61704,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -66381,11 +61792,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -66522,16 +61937,6 @@ private constructor( */ @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]. * @@ -66648,7 +62053,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewFloatingCumulativeGroupedBulkPrice]. + * [CumulativeGroupedBulk]. * * The following fields are required: * ```java @@ -66656,14 +62061,13 @@ private constructor( * .cumulativeGroupedBulkConfig() * .currency() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewFloatingCumulativeGroupedBulkPrice]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -66672,7 +62076,7 @@ private constructor( null private var currency: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -66689,32 +62093,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newFloatingCumulativeGroupedBulkPrice: NewFloatingCumulativeGroupedBulkPrice - ) = apply { - cadence = newFloatingCumulativeGroupedBulkPrice.cadence + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence cumulativeGroupedBulkConfig = - newFloatingCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - currency = newFloatingCumulativeGroupedBulkPrice.currency - itemId = newFloatingCumulativeGroupedBulkPrice.itemId - modelType = newFloatingCumulativeGroupedBulkPrice.modelType - name = newFloatingCumulativeGroupedBulkPrice.name - billableMetricId = newFloatingCumulativeGroupedBulkPrice.billableMetricId - billedInAdvance = newFloatingCumulativeGroupedBulkPrice.billedInAdvance - billingCycleConfiguration = - newFloatingCumulativeGroupedBulkPrice.billingCycleConfiguration - conversionRate = newFloatingCumulativeGroupedBulkPrice.conversionRate - externalPriceId = newFloatingCumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = - newFloatingCumulativeGroupedBulkPrice.fixedPriceQuantity - invoiceGroupingKey = - newFloatingCumulativeGroupedBulkPrice.invoiceGroupingKey + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + currency = cumulativeGroupedBulk.currency + itemId = cumulativeGroupedBulk.itemId + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey invoicingCycleConfiguration = - newFloatingCumulativeGroupedBulkPrice.invoicingCycleConfiguration - metadata = newFloatingCumulativeGroupedBulkPrice.metadata + cumulativeGroupedBulk.invoicingCycleConfiguration + metadata = cumulativeGroupedBulk.metadata additionalProperties = - newFloatingCumulativeGroupedBulkPrice.additionalProperties - .toMutableMap() + cumulativeGroupedBulk.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -66769,18 +62167,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -67061,7 +62460,7 @@ private constructor( } /** - * Returns an immutable instance of [NewFloatingCumulativeGroupedBulkPrice]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -67071,14 +62470,13 @@ private constructor( * .cumulativeGroupedBulkConfig() * .currency() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewFloatingCumulativeGroupedBulkPrice = - NewFloatingCumulativeGroupedBulkPrice( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("cadence", cadence), checkRequired( "cumulativeGroupedBulkConfig", @@ -67086,7 +62484,7 @@ private constructor( ), checkRequired("currency", currency), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -67103,7 +62501,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewFloatingCumulativeGroupedBulkPrice = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -67112,7 +62510,11 @@ private constructor( cumulativeGroupedBulkConfig().validate() currency() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -67146,7 +62548,9 @@ private constructor( (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -67432,135 +62836,6 @@ private constructor( "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * 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 { - CUMULATIVE_GROUPED_BULK, - /** - * 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) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -68399,7 +63674,7 @@ 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CumulativeGroupedBulk && 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 && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -68409,7 +63684,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewFloatingCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } } @@ -68563,32 +63838,26 @@ private constructor( /** * Alias for calling [adjustment] with - * `Adjustment.ofNewPercentageDiscount(newPercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewUsageDiscount(newUsageDiscount)`. - */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewAmountDiscount(newAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMinimum(newMinimum)`. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMaximum(newMaximum)`. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** * The start date of the adjustment interval. This is the date that the adjustment will @@ -68726,60 +63995,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isNewMinimum(): Boolean = newMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isNewMaximum(): Boolean = newMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) + 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) } @@ -68791,27 +64056,27 @@ private constructor( } accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - newPercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -68836,19 +64101,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) = newPercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - newUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - newAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -68859,19 +64124,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ + 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 hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" + 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") } @@ -68879,22 +64144,20 @@ private constructor( companion object { @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -68903,15 +64166,15 @@ private constructor( */ interface Visitor { - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitNewMinimum(newMinimum: NewMinimum): T + fun visitMinimum(minimum: Minimum): T - fun visitNewMaximum(newMaximum: NewMaximum): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -68937,28 +64200,28 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(newPercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newUsageDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newAmountDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMinimum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMaximum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) } ?: Adjustment(_json = json) } } @@ -68975,23 +64238,21 @@ private constructor( provider: SerializerProvider, ) { when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) + 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") } } } - class NewPercentageDiscount + class PercentageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val percentageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -69002,7 +64263,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -69021,11 +64282,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -69055,16 +64322,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -69111,11 +64368,10 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPercentageDiscount]. + * [PercentageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` @@ -69123,37 +64379,39 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPercentageDiscount]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var percentageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.percentageDiscount = percentageDiscount.percentageDiscount + isInvoiceLevel = percentageDiscount.isInvoiceLevel additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -69239,22 +64497,21 @@ private constructor( } /** - * Returns an immutable instance of [NewPercentageDiscount]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): PercentageDiscount = + PercentageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -69266,12 +64523,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPercentageDiscount = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() percentageDiscount() isInvoiceLevel() @@ -69294,147 +64557,19 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -69444,12 +64579,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "PercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewUsageDiscount + class UsageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val usageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -69460,7 +64595,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -69479,11 +64614,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -69512,16 +64653,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -69567,11 +64698,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewUsageDiscount]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` @@ -69579,36 +64709,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewUsageDiscount]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var usageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.usageDiscount = usageDiscount.usageDiscount + isInvoiceLevel = usageDiscount.isInvoiceLevel + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -69694,22 +64826,21 @@ private constructor( } /** - * Returns an immutable instance of [NewUsageDiscount]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): UsageDiscount = + UsageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -69721,12 +64852,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewUsageDiscount = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() usageDiscount() isInvoiceLevel() @@ -69749,147 +64886,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("usage_discount")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -69899,12 +64906,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "UsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewAmountDiscount + class AmountDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -69915,7 +64922,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -69934,11 +64941,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -69967,16 +64980,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -70022,12 +65025,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewAmountDiscount]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` @@ -70035,36 +65036,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewAmountDiscount]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -70150,22 +65153,21 @@ private constructor( } /** - * Returns an immutable instance of [NewAmountDiscount]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): AmountDiscount = + AmountDiscount( + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -70177,12 +65179,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewAmountDiscount = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -70205,147 +65213,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("amount_discount")) 1 else 0 } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -70355,12 +65233,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "AmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMinimum + class Minimum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val itemId: JsonField, private val minimumAmount: JsonField, @@ -70372,7 +65250,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -70395,11 +65273,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -70437,16 +65321,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -70500,11 +65374,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMinimum]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -70513,10 +65386,10 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMinimum]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var itemId: JsonField? = null private var minimumAmount: JsonField? = null @@ -70524,26 +65397,28 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() + internal fun from(minimum: Minimum) = apply { + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + isInvoiceLevel = minimum.isInvoiceLevel + additionalProperties = minimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -70641,13 +65516,12 @@ private constructor( } /** - * Returns an immutable instance of [NewMinimum]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -70655,9 +65529,9 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Minimum = + Minimum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -70670,12 +65544,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMinimum = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() itemId() minimumAmount() @@ -70699,148 +65579,18 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -70850,12 +65600,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Minimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMaximum + class Maximum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val maximumAmount: JsonField, private val isInvoiceLevel: JsonField, @@ -70866,7 +65616,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -70885,11 +65635,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -70918,16 +65674,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -70973,11 +65719,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMaximum]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` @@ -70985,35 +65730,37 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMaximum]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var maximumAmount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() + internal fun from(maximum: Maximum) = apply { + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + maximumAmount = maximum.maximumAmount + isInvoiceLevel = maximum.isInvoiceLevel + additionalProperties = maximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -71099,22 +65846,21 @@ private constructor( } /** - * Returns an immutable instance of [NewMaximum]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Maximum = + Maximum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -71126,12 +65872,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMaximum = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() maximumAmount() isInvoiceLevel() @@ -71154,147 +65906,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -71304,7 +65926,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Maximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } } @@ -71355,7 +65977,7 @@ private constructor( } accept( - object : Visitor { + object : Visitor { override fun visitDateTime(dateTime: OffsetDateTime) {} override fun visitBillingCycleRelative( @@ -71543,7 +66165,7 @@ private constructor( } accept( - object : Visitor { + object : Visitor { override fun visitDateTime(dateTime: OffsetDateTime) {} override fun visitBillingCycleRelative( @@ -72266,7 +66888,7 @@ private constructor( } accept( - object : Visitor { + object : Visitor { override fun visitDateTime(dateTime: OffsetDateTime) {} override fun visitBillingCycleRelative( @@ -72666,7 +67288,7 @@ private constructor( } accept( - object : Visitor { + object : Visitor { override fun visitDateTime(dateTime: OffsetDateTime) {} override fun visitBillingCycleRelative( @@ -73126,7 +67748,7 @@ private constructor( } accept( - object : Visitor { + object : Visitor { override fun visitDateTime(dateTime: OffsetDateTime) {} override fun visitBillingCycleRelative( @@ -73312,7 +67934,7 @@ private constructor( } accept( - object : Visitor { + object : Visitor { override fun visitDateTime(dateTime: OffsetDateTime) {} override fun visitBillingCycleRelative( diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt index 795bbc12..37aa00af 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt @@ -1067,17 +1067,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1721,41 +1721,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1904,66 +1891,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1976,34 +1953,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2028,25 +1997,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2057,21 +2020,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2079,27 +2040,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2108,21 +2062,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2148,44 +2096,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2201,26 +2134,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2234,7 +2163,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2269,11 +2198,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2329,16 +2264,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2402,13 +2327,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2419,11 +2342,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2432,21 +2355,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2460,17 +2378,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2605,14 +2525,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2622,10 +2541,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2639,13 +2558,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2671,149 +2596,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2823,13 +2620,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2843,7 +2640,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2878,11 +2675,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2938,16 +2741,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3011,13 +2804,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3028,11 +2819,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3041,21 +2832,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3069,17 +2855,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3214,14 +3002,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3231,10 +3018,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3248,13 +3035,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3280,149 +3073,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3432,13 +3097,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3452,7 +3117,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3487,11 +3152,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3548,16 +3219,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3622,12 +3283,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3638,11 +3298,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3651,23 +3311,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3681,17 +3335,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3826,14 +3482,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3843,10 +3498,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3860,13 +3515,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3892,149 +3553,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4044,13 +3577,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4065,7 +3598,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4104,11 +3637,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4174,19 +3713,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4254,13 +3783,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4272,11 +3799,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4286,22 +3813,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4314,17 +3836,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4471,14 +3995,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4489,10 +4012,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4507,13 +4030,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4540,7 +4069,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4548,142 +4077,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4693,13 +4092,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4713,7 +4112,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4748,11 +4147,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4808,16 +4213,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4881,13 +4276,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4898,11 +4291,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4911,21 +4304,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4938,17 +4326,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5083,14 +4473,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5100,10 +4489,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5117,13 +4506,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5149,149 +4544,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5301,7 +4566,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5594,17 +4859,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5612,11 +4877,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5637,15 +4902,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5671,12 +4936,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5703,14 +4967,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5719,11 +4981,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5749,17 +5011,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5786,12 +5048,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5810,7 +5072,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5857,11 +5119,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5910,16 +5178,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5954,15 +5212,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5970,29 +5226,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6067,17 +5321,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6133,7 +5389,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6142,15 +5398,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6158,7 +5413,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6167,7 +5422,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6175,7 +5430,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6200,143 +5459,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6346,14 +5478,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6370,7 +5502,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6411,11 +5543,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6463,16 +5601,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6517,14 +5645,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6533,31 +5659,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6617,17 +5739,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6700,7 +5824,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6708,7 +5832,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6716,15 +5839,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6734,14 +5857,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6766,144 +5893,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6913,14 +5913,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6937,7 +5937,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6978,11 +5978,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7031,16 +6037,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7085,14 +6081,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7101,28 +6095,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7182,17 +6175,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7266,7 +6261,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7274,7 +6269,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7282,15 +6276,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7300,14 +6294,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7332,144 +6330,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7479,7 +6350,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9279,142 +8150,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 851d0151..3d9b6d1d 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 @@ -32,6 +32,7 @@ import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.Unit as KUnit import kotlin.jvm.optionals.getOrNull /** @@ -196,13 +197,13 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionSchedulePlanChangeParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -652,7 +653,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .changeOption() * ``` */ @@ -678,7 +678,11 @@ private constructor( subscriptionSchedulePlanChangeParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Sets the entire request body. @@ -1535,7 +1539,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .changeOption() * ``` * @@ -1543,7 +1546,7 @@ private constructor( */ fun build(): SubscriptionSchedulePlanChangeParams = SubscriptionSchedulePlanChangeParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -1554,7 +1557,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } @@ -3495,32 +3498,26 @@ private constructor( /** * Alias for calling [adjustment] with - * `Adjustment.ofNewPercentageDiscount(newPercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewUsageDiscount(newUsageDiscount)`. - */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewAmountDiscount(newAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMinimum(newMinimum)`. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMaximum(newMaximum)`. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** * The end date of the adjustment interval. This is the date that the adjustment will @@ -3668,60 +3665,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isNewMinimum(): Boolean = newMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isNewMaximum(): Boolean = newMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) + 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) } @@ -3733,27 +3726,27 @@ private constructor( } accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - newPercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -3778,19 +3771,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) = newPercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - newUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - newAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -3801,19 +3794,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ + 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 hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" + 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") } @@ -3821,22 +3814,20 @@ private constructor( companion object { @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -3845,15 +3836,15 @@ private constructor( */ interface Visitor { - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitNewMinimum(newMinimum: NewMinimum): T + fun visitMinimum(minimum: Minimum): T - fun visitNewMaximum(newMaximum: NewMaximum): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -3879,28 +3870,28 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(newPercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newUsageDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newAmountDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMinimum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMaximum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) } ?: Adjustment(_json = json) } } @@ -3917,23 +3908,21 @@ private constructor( provider: SerializerProvider, ) { when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) + 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") } } } - class NewPercentageDiscount + class PercentageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val percentageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -3944,7 +3933,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3963,11 +3952,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -3997,16 +3992,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4053,11 +4038,10 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPercentageDiscount]. + * [PercentageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` @@ -4065,37 +4049,39 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPercentageDiscount]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var percentageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.percentageDiscount = percentageDiscount.percentageDiscount + isInvoiceLevel = percentageDiscount.isInvoiceLevel additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4181,22 +4167,21 @@ private constructor( } /** - * Returns an immutable instance of [NewPercentageDiscount]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): PercentageDiscount = + PercentageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4208,12 +4193,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPercentageDiscount = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() percentageDiscount() isInvoiceLevel() @@ -4236,147 +4227,19 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4386,12 +4249,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "PercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewUsageDiscount + class UsageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val usageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -4402,7 +4265,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4421,11 +4284,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -4454,16 +4323,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4509,11 +4368,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewUsageDiscount]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` @@ -4521,36 +4379,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewUsageDiscount]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var usageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.usageDiscount = usageDiscount.usageDiscount + isInvoiceLevel = usageDiscount.isInvoiceLevel + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4636,22 +4496,21 @@ private constructor( } /** - * Returns an immutable instance of [NewUsageDiscount]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): UsageDiscount = + UsageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4663,12 +4522,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewUsageDiscount = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() usageDiscount() isInvoiceLevel() @@ -4691,147 +4556,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("usage_discount")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4841,12 +4576,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "UsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewAmountDiscount + class AmountDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -4857,7 +4592,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -4876,11 +4611,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -4909,16 +4650,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -4964,12 +4695,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewAmountDiscount]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` @@ -4977,36 +4706,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewAmountDiscount]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5092,22 +4823,21 @@ private constructor( } /** - * Returns an immutable instance of [NewAmountDiscount]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): AmountDiscount = + AmountDiscount( + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -5119,12 +4849,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewAmountDiscount = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -5147,147 +4883,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("amount_discount")) 1 else 0 } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5297,12 +4903,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "AmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMinimum + class Minimum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val itemId: JsonField, private val minimumAmount: JsonField, @@ -5314,7 +4920,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -5337,11 +4943,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -5379,16 +4991,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -5442,11 +5044,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMinimum]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -5455,10 +5056,10 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMinimum]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var itemId: JsonField? = null private var minimumAmount: JsonField? = null @@ -5466,26 +5067,28 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() + internal fun from(minimum: Minimum) = apply { + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + isInvoiceLevel = minimum.isInvoiceLevel + additionalProperties = minimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5583,13 +5186,12 @@ private constructor( } /** - * Returns an immutable instance of [NewMinimum]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -5597,9 +5199,9 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Minimum = + Minimum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5612,12 +5214,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMinimum = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() itemId() minimumAmount() @@ -5641,148 +5249,18 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5792,12 +5270,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Minimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMaximum + class Maximum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val maximumAmount: JsonField, private val isInvoiceLevel: JsonField, @@ -5808,7 +5286,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -5827,11 +5305,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -5860,16 +5344,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -5915,11 +5389,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMaximum]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` @@ -5927,35 +5400,37 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMaximum]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var maximumAmount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() + internal fun from(maximum: Maximum) = apply { + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + maximumAmount = maximum.maximumAmount + isInvoiceLevel = maximum.isInvoiceLevel + additionalProperties = maximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -6041,22 +5516,21 @@ private constructor( } /** - * Returns an immutable instance of [NewMaximum]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Maximum = + Maximum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -6068,12 +5542,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMaximum = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() maximumAmount() isInvoiceLevel() @@ -6096,147 +5576,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6246,7 +5596,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Maximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } } @@ -6738,244 +6088,127 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } - /** - * Alias for calling [price] with `Price.ofNewSubscriptionUnit(newSubscriptionUnit)`. - */ - fun price(newSubscriptionUnit: Price.NewSubscriptionUnitPrice) = - price(Price.ofNewSubscriptionUnit(newSubscriptionUnit)) + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionPackage(newSubscriptionPackage)`. - */ - fun price(newSubscriptionPackage: Price.NewSubscriptionPackagePrice) = - price(Price.ofNewSubscriptionPackage(newSubscriptionPackage)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)`. - */ - fun price(newSubscriptionMatrix: Price.NewSubscriptionMatrixPrice) = - price(Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)) + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTiered(newSubscriptionTiered)`. - */ - fun price(newSubscriptionTiered: Price.NewSubscriptionTieredPrice) = - price(Price.ofNewSubscriptionTiered(newSubscriptionTiered)) + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)`. - */ - fun price(newSubscriptionTieredBps: Price.NewSubscriptionTieredBpsPrice) = - price(Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)) + /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - /** Alias for calling [price] with `Price.ofNewSubscriptionBps(newSubscriptionBps)`. */ - fun price(newSubscriptionBps: Price.NewSubscriptionBpsPrice) = - price(Price.ofNewSubscriptionBps(newSubscriptionBps)) + /** Alias for calling [price] with `Price.ofBps(bps)`. */ + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)`. - */ - fun price(newSubscriptionBulkBps: Price.NewSubscriptionBulkBpsPrice) = - price(Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)) + /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** - * Alias for calling [price] with `Price.ofNewSubscriptionBulk(newSubscriptionBulk)`. - */ - fun price(newSubscriptionBulk: Price.NewSubscriptionBulkPrice) = - price(Price.ofNewSubscriptionBulk(newSubscriptionBulk)) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount)`. + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price( - newSubscriptionThresholdTotalAmount: Price.NewSubscriptionThresholdTotalAmountPrice - ) = - price( - Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount) - ) + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)`. - */ - fun price(newSubscriptionTieredPackage: Price.NewSubscriptionTieredPackagePrice) = - price(Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)) + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: Price.TieredPackage) = + price(Price.ofTieredPackage(tieredPackage)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)`. - */ - fun price( - newSubscriptionTieredWithMinimum: Price.NewSubscriptionTieredWithMinimumPrice - ) = price(Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: Price.TieredWithMinimum) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)`. - */ - fun price(newSubscriptionUnitWithPercent: Price.NewSubscriptionUnitWithPercentPrice) = - price(Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: Price.UnitWithPercent) = + price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionPackageWithAllocation(newSubscriptionPackageWithAllocation)`. + * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price( - newSubscriptionPackageWithAllocation: - Price.NewSubscriptionPackageWithAllocationPrice - ) = - price( - Price.ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - ) + fun price(packageWithAllocation: Price.PackageWithAllocation) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)`. + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price( - newSubscriptionTierWithProration: Price.NewSubscriptionTierWithProrationPrice - ) = price(Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)) + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)`. - */ - fun price( - newSubscriptionUnitWithProration: Price.NewSubscriptionUnitWithProrationPrice - ) = price(Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: Price.UnitWithProration) = + price(Price.ofUnitWithProration(unitWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)`. - */ - fun price( - newSubscriptionGroupedAllocation: Price.NewSubscriptionGroupedAllocationPrice - ) = price(Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)) + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: Price.GroupedAllocation) = + price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedWithProratedMinimum(newSubscriptionGroupedWithProratedMinimum)`. + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price( - newSubscriptionGroupedWithProratedMinimum: - Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - ) + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)`. - */ - fun price( - newSubscriptionBulkWithProration: Price.NewSubscriptionBulkWithProrationPrice - ) = price(Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionScalableMatrixWithUnitPricing(newSubscriptionScalableMatrixWithUnitPricing)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price( - newSubscriptionScalableMatrixWithUnitPricing: - Price.NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = - price( - Price.ofNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing - ) - ) + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionScalableMatrixWithTieredPricing(newSubscriptionScalableMatrixWithTieredPricing)`. + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - newSubscriptionScalableMatrixWithTieredPricing: - Price.NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = - price( - Price.ofNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing - ) - ) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionCumulativeGroupedBulk(newSubscriptionCumulativeGroupedBulk)`. + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price( - newSubscriptionCumulativeGroupedBulk: - Price.NewSubscriptionCumulativeGroupedBulkPrice - ) = - price( - Price.ofNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk - ) - ) + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionMaxGroupTieredPackage(newSubscriptionMaxGroupTieredPackage)`. + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price( - newSubscriptionMaxGroupTieredPackage: - Price.NewSubscriptionMaxGroupTieredPackagePrice - ) = - price( - Price.ofNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage - ) - ) + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedWithMeteredMinimum(newSubscriptionGroupedWithMeteredMinimum)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price( - newSubscriptionGroupedWithMeteredMinimum: - Price.NewSubscriptionGroupedWithMeteredMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum - ) - ) + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionMatrixWithDisplayName(newSubscriptionMatrixWithDisplayName)`. + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price( - newSubscriptionMatrixWithDisplayName: - Price.NewSubscriptionMatrixWithDisplayNamePrice - ) = - price( - Price.ofNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName - ) - ) + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedTieredPackage(newSubscriptionGroupedTieredPackage)`. + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price( - newSubscriptionGroupedTieredPackage: Price.NewSubscriptionGroupedTieredPackagePrice - ) = - price( - Price.ofNewSubscriptionGroupedTieredPackage(newSubscriptionGroupedTieredPackage) - ) + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -8043,401 +7276,257 @@ private constructor( @JsonSerialize(using = Price.Serializer::class) class Price private constructor( - private val newSubscriptionUnit: NewSubscriptionUnitPrice? = null, - private val newSubscriptionPackage: NewSubscriptionPackagePrice? = null, - private val newSubscriptionMatrix: NewSubscriptionMatrixPrice? = null, - private val newSubscriptionTiered: NewSubscriptionTieredPrice? = null, - private val newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice? = null, - private val newSubscriptionBps: NewSubscriptionBpsPrice? = null, - private val newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice? = null, - private val newSubscriptionBulk: NewSubscriptionBulkPrice? = null, - private val newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice? = - null, - private val newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = - null, - private val newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice? = - null, - private val newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice? = - null, - private val newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice? = - null, - private val newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice? = - null, - private val newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice? = - null, - private val newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice? = - null, - private val newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice? = - null, - private val newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice? = - null, - private val newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice? = - null, + 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 thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val bulkWithProration: BulkWithProration? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, private val _json: JsonValue? = null, ) { - fun newSubscriptionUnit(): Optional = - Optional.ofNullable(newSubscriptionUnit) + fun unit(): Optional = Optional.ofNullable(unit) - fun newSubscriptionPackage(): Optional = - Optional.ofNullable(newSubscriptionPackage) + fun package_(): Optional = Optional.ofNullable(package_) - fun newSubscriptionMatrix(): Optional = - Optional.ofNullable(newSubscriptionMatrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun newSubscriptionTiered(): Optional = - Optional.ofNullable(newSubscriptionTiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun newSubscriptionTieredBps(): Optional = - Optional.ofNullable(newSubscriptionTieredBps) + fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - fun newSubscriptionBps(): Optional = - Optional.ofNullable(newSubscriptionBps) + fun bps(): Optional = Optional.ofNullable(bps) - fun newSubscriptionBulkBps(): Optional = - Optional.ofNullable(newSubscriptionBulkBps) + fun bulkBps(): Optional = Optional.ofNullable(bulkBps) - fun newSubscriptionBulk(): Optional = - Optional.ofNullable(newSubscriptionBulk) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun newSubscriptionThresholdTotalAmount(): - Optional = - Optional.ofNullable(newSubscriptionThresholdTotalAmount) + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) - fun newSubscriptionTieredPackage(): Optional = - Optional.ofNullable(newSubscriptionTieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun newSubscriptionTieredWithMinimum(): - Optional = - Optional.ofNullable(newSubscriptionTieredWithMinimum) + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) - fun newSubscriptionUnitWithPercent(): Optional = - Optional.ofNullable(newSubscriptionUnitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun newSubscriptionPackageWithAllocation(): - Optional = - Optional.ofNullable(newSubscriptionPackageWithAllocation) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) - fun newSubscriptionTierWithProration(): - Optional = - Optional.ofNullable(newSubscriptionTierWithProration) + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) - fun newSubscriptionUnitWithProration(): - Optional = - Optional.ofNullable(newSubscriptionUnitWithProration) + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) - fun newSubscriptionGroupedAllocation(): - Optional = - Optional.ofNullable(newSubscriptionGroupedAllocation) + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) - fun newSubscriptionGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithProratedMinimum) + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) - fun newSubscriptionBulkWithProration(): - Optional = - Optional.ofNullable(newSubscriptionBulkWithProration) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) - fun newSubscriptionScalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(newSubscriptionScalableMatrixWithUnitPricing) + fun scalableMatrixWithUnitPricing(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) - fun newSubscriptionScalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(newSubscriptionScalableMatrixWithTieredPricing) + fun scalableMatrixWithTieredPricing(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) - fun newSubscriptionCumulativeGroupedBulk(): - Optional = - Optional.ofNullable(newSubscriptionCumulativeGroupedBulk) + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) - fun newSubscriptionMaxGroupTieredPackage(): - Optional = - Optional.ofNullable(newSubscriptionMaxGroupTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) - fun newSubscriptionGroupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithMeteredMinimum) + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) - fun newSubscriptionMatrixWithDisplayName(): - Optional = - Optional.ofNullable(newSubscriptionMatrixWithDisplayName) + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) - fun newSubscriptionGroupedTieredPackage(): - Optional = - Optional.ofNullable(newSubscriptionGroupedTieredPackage) + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) - fun isNewSubscriptionUnit(): Boolean = newSubscriptionUnit != null + fun isUnit(): Boolean = unit != null - fun isNewSubscriptionPackage(): Boolean = newSubscriptionPackage != null + fun isPackage(): Boolean = package_ != null - fun isNewSubscriptionMatrix(): Boolean = newSubscriptionMatrix != null + fun isMatrix(): Boolean = matrix != null - fun isNewSubscriptionTiered(): Boolean = newSubscriptionTiered != null + fun isTiered(): Boolean = tiered != null - fun isNewSubscriptionTieredBps(): Boolean = newSubscriptionTieredBps != null + fun isTieredBps(): Boolean = tieredBps != null - fun isNewSubscriptionBps(): Boolean = newSubscriptionBps != null + fun isBps(): Boolean = bps != null - fun isNewSubscriptionBulkBps(): Boolean = newSubscriptionBulkBps != null + fun isBulkBps(): Boolean = bulkBps != null - fun isNewSubscriptionBulk(): Boolean = newSubscriptionBulk != null + fun isBulk(): Boolean = bulk != null - fun isNewSubscriptionThresholdTotalAmount(): Boolean = - newSubscriptionThresholdTotalAmount != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isNewSubscriptionTieredPackage(): Boolean = newSubscriptionTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null - fun isNewSubscriptionTieredWithMinimum(): Boolean = - newSubscriptionTieredWithMinimum != null + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isNewSubscriptionUnitWithPercent(): Boolean = newSubscriptionUnitWithPercent != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun isNewSubscriptionPackageWithAllocation(): Boolean = - newSubscriptionPackageWithAllocation != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun isNewSubscriptionTierWithProration(): Boolean = - newSubscriptionTierWithProration != null + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun isNewSubscriptionUnitWithProration(): Boolean = - newSubscriptionUnitWithProration != null + fun isUnitWithProration(): Boolean = unitWithProration != null - fun isNewSubscriptionGroupedAllocation(): Boolean = - newSubscriptionGroupedAllocation != null + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isNewSubscriptionGroupedWithProratedMinimum(): Boolean = - newSubscriptionGroupedWithProratedMinimum != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun isNewSubscriptionBulkWithProration(): Boolean = - newSubscriptionBulkWithProration != null + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isNewSubscriptionScalableMatrixWithUnitPricing(): Boolean = - newSubscriptionScalableMatrixWithUnitPricing != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isNewSubscriptionScalableMatrixWithTieredPricing(): Boolean = - newSubscriptionScalableMatrixWithTieredPricing != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isNewSubscriptionCumulativeGroupedBulk(): Boolean = - newSubscriptionCumulativeGroupedBulk != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isNewSubscriptionMaxGroupTieredPackage(): Boolean = - newSubscriptionMaxGroupTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isNewSubscriptionGroupedWithMeteredMinimum(): Boolean = - newSubscriptionGroupedWithMeteredMinimum != null + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isNewSubscriptionMatrixWithDisplayName(): Boolean = - newSubscriptionMatrixWithDisplayName != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isNewSubscriptionGroupedTieredPackage(): Boolean = - newSubscriptionGroupedTieredPackage != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun asNewSubscriptionUnit(): NewSubscriptionUnitPrice = - newSubscriptionUnit.getOrThrow("newSubscriptionUnit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asNewSubscriptionPackage(): NewSubscriptionPackagePrice = - newSubscriptionPackage.getOrThrow("newSubscriptionPackage") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asNewSubscriptionMatrix(): NewSubscriptionMatrixPrice = - newSubscriptionMatrix.getOrThrow("newSubscriptionMatrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asNewSubscriptionTiered(): NewSubscriptionTieredPrice = - newSubscriptionTiered.getOrThrow("newSubscriptionTiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asNewSubscriptionTieredBps(): NewSubscriptionTieredBpsPrice = - newSubscriptionTieredBps.getOrThrow("newSubscriptionTieredBps") + fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - fun asNewSubscriptionBps(): NewSubscriptionBpsPrice = - newSubscriptionBps.getOrThrow("newSubscriptionBps") + fun asBps(): Bps = bps.getOrThrow("bps") - fun asNewSubscriptionBulkBps(): NewSubscriptionBulkBpsPrice = - newSubscriptionBulkBps.getOrThrow("newSubscriptionBulkBps") + fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") - fun asNewSubscriptionBulk(): NewSubscriptionBulkPrice = - newSubscriptionBulk.getOrThrow("newSubscriptionBulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") - fun asNewSubscriptionThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - newSubscriptionThresholdTotalAmount.getOrThrow( - "newSubscriptionThresholdTotalAmount" - ) + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asNewSubscriptionTieredPackage(): NewSubscriptionTieredPackagePrice = - newSubscriptionTieredPackage.getOrThrow("newSubscriptionTieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asNewSubscriptionTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - newSubscriptionTieredWithMinimum.getOrThrow("newSubscriptionTieredWithMinimum") + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asNewSubscriptionUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - newSubscriptionUnitWithPercent.getOrThrow("newSubscriptionUnitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asNewSubscriptionPackageWithAllocation(): - NewSubscriptionPackageWithAllocationPrice = - newSubscriptionPackageWithAllocation.getOrThrow( - "newSubscriptionPackageWithAllocation" - ) + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") - fun asNewSubscriptionTierWithProration(): NewSubscriptionTierWithProrationPrice = - newSubscriptionTierWithProration.getOrThrow("newSubscriptionTierWithProration") + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") - fun asNewSubscriptionUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - newSubscriptionUnitWithProration.getOrThrow("newSubscriptionUnitWithProration") + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") - fun asNewSubscriptionGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - newSubscriptionGroupedAllocation.getOrThrow("newSubscriptionGroupedAllocation") + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") - fun asNewSubscriptionGroupedWithProratedMinimum(): - NewSubscriptionGroupedWithProratedMinimumPrice = - newSubscriptionGroupedWithProratedMinimum.getOrThrow( - "newSubscriptionGroupedWithProratedMinimum" - ) + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asNewSubscriptionBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - newSubscriptionBulkWithProration.getOrThrow("newSubscriptionBulkWithProration") + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") - fun asNewSubscriptionScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - newSubscriptionScalableMatrixWithUnitPricing.getOrThrow( - "newSubscriptionScalableMatrixWithUnitPricing" - ) + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asNewSubscriptionScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - newSubscriptionScalableMatrixWithTieredPricing.getOrThrow( - "newSubscriptionScalableMatrixWithTieredPricing" - ) + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asNewSubscriptionCumulativeGroupedBulk(): - NewSubscriptionCumulativeGroupedBulkPrice = - newSubscriptionCumulativeGroupedBulk.getOrThrow( - "newSubscriptionCumulativeGroupedBulk" - ) + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asNewSubscriptionMaxGroupTieredPackage(): - NewSubscriptionMaxGroupTieredPackagePrice = - newSubscriptionMaxGroupTieredPackage.getOrThrow( - "newSubscriptionMaxGroupTieredPackage" - ) + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asNewSubscriptionGroupedWithMeteredMinimum(): - NewSubscriptionGroupedWithMeteredMinimumPrice = - newSubscriptionGroupedWithMeteredMinimum.getOrThrow( - "newSubscriptionGroupedWithMeteredMinimum" - ) + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - fun asNewSubscriptionMatrixWithDisplayName(): - NewSubscriptionMatrixWithDisplayNamePrice = - newSubscriptionMatrixWithDisplayName.getOrThrow( - "newSubscriptionMatrixWithDisplayName" - ) + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asNewSubscriptionGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - newSubscriptionGroupedTieredPackage.getOrThrow( - "newSubscriptionGroupedTieredPackage" - ) + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newSubscriptionUnit != null -> - visitor.visitNewSubscriptionUnit(newSubscriptionUnit) - newSubscriptionPackage != null -> - visitor.visitNewSubscriptionPackage(newSubscriptionPackage) - newSubscriptionMatrix != null -> - visitor.visitNewSubscriptionMatrix(newSubscriptionMatrix) - newSubscriptionTiered != null -> - visitor.visitNewSubscriptionTiered(newSubscriptionTiered) - newSubscriptionTieredBps != null -> - visitor.visitNewSubscriptionTieredBps(newSubscriptionTieredBps) - newSubscriptionBps != null -> - visitor.visitNewSubscriptionBps(newSubscriptionBps) - newSubscriptionBulkBps != null -> - visitor.visitNewSubscriptionBulkBps(newSubscriptionBulkBps) - newSubscriptionBulk != null -> - visitor.visitNewSubscriptionBulk(newSubscriptionBulk) - newSubscriptionThresholdTotalAmount != null -> - visitor.visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount - ) - newSubscriptionTieredPackage != null -> - visitor.visitNewSubscriptionTieredPackage(newSubscriptionTieredPackage) - newSubscriptionTieredWithMinimum != null -> - visitor.visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum - ) - newSubscriptionUnitWithPercent != null -> - visitor.visitNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent) - newSubscriptionPackageWithAllocation != null -> - visitor.visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - newSubscriptionTierWithProration != null -> - visitor.visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration - ) - newSubscriptionUnitWithProration != null -> - visitor.visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration - ) - newSubscriptionGroupedAllocation != null -> - visitor.visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation - ) - newSubscriptionGroupedWithProratedMinimum != null -> - visitor.visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - newSubscriptionBulkWithProration != null -> - visitor.visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration - ) - newSubscriptionScalableMatrixWithUnitPricing != null -> - visitor.visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing - ) - newSubscriptionScalableMatrixWithTieredPricing != null -> - visitor.visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing - ) - newSubscriptionCumulativeGroupedBulk != null -> - visitor.visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk - ) - newSubscriptionMaxGroupTieredPackage != null -> - visitor.visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage - ) - newSubscriptionGroupedWithMeteredMinimum != null -> - visitor.visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum - ) - newSubscriptionMatrixWithDisplayName != null -> - visitor.visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName - ) - newSubscriptionGroupedTieredPackage != null -> - visitor.visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + tieredBps != null -> visitor.visitTieredBps(tieredBps) + bps != null -> visitor.visitBps(bps) + bulkBps != null -> visitor.visitBulkBps(bulkBps) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) else -> visitor.unknown(_json) } @@ -8449,165 +7538,127 @@ private constructor( } accept( - object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) { - newSubscriptionUnit.validate() + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() } - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) { - newSubscriptionPackage.validate() + override fun visitPackage(package_: Package) { + package_.validate() } - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) { - newSubscriptionMatrix.validate() + override fun visitMatrix(matrix: Matrix) { + matrix.validate() } - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) { - newSubscriptionTiered.validate() + override fun visitTiered(tiered: Tiered) { + tiered.validate() } - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) { - newSubscriptionTieredBps.validate() + override fun visitTieredBps(tieredBps: TieredBps) { + tieredBps.validate() } - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) { - newSubscriptionBps.validate() + override fun visitBps(bps: Bps) { + bps.validate() } - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) { - newSubscriptionBulkBps.validate() + override fun visitBulkBps(bulkBps: BulkBps) { + bulkBps.validate() } - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) { - newSubscriptionBulk.validate() + override fun visitBulk(bulk: Bulk) { + bulk.validate() } - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount ) { - newSubscriptionThresholdTotalAmount.validate() + thresholdTotalAmount.validate() } - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) { - newSubscriptionTieredPackage.validate() + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() } - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - newSubscriptionTieredWithMinimum.validate() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() } - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - newSubscriptionUnitWithPercent.validate() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() } - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation ) { - newSubscriptionPackageWithAllocation.validate() + packageWithAllocation.validate() } - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration ) { - newSubscriptionTierWithProration.validate() + tieredWithProration.validate() } - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - newSubscriptionUnitWithProration.validate() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() } - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - newSubscriptionGroupedAllocation.validate() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() } - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { - newSubscriptionGroupedWithProratedMinimum.validate() + groupedWithProratedMinimum.validate() } - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - newSubscriptionBulkWithProration.validate() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() } - override fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { - newSubscriptionScalableMatrixWithUnitPricing.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { - newSubscriptionScalableMatrixWithTieredPricing.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk ) { - newSubscriptionCumulativeGroupedBulk.validate() + cumulativeGroupedBulk.validate() } - override fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage ) { - newSubscriptionMaxGroupTieredPackage.validate() + maxGroupTieredPackage.validate() } - override fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { - newSubscriptionGroupedWithMeteredMinimum.validate() + groupedWithMeteredMinimum.validate() } - override fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName ) { - newSubscriptionMatrixWithDisplayName.validate() + matrixWithDisplayName.validate() } - override fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage ) { - newSubscriptionGroupedTieredPackage.validate() + groupedTieredPackage.validate() } } ) @@ -8632,115 +7683,83 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) = newSubscriptionUnit.validity() - - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) = newSubscriptionPackage.validity() - - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) = newSubscriptionMatrix.validity() - - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) = newSubscriptionTiered.validity() - - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = newSubscriptionTieredBps.validity() - - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) = newSubscriptionBps.validity() - - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) = newSubscriptionBulkBps.validity() - - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) = newSubscriptionBulk.validity() - - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice - ) = newSubscriptionThresholdTotalAmount.validity() - - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = newSubscriptionTieredPackage.validity() - - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = newSubscriptionTieredWithMinimum.validity() - - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = newSubscriptionUnitWithPercent.validity() - - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice - ) = newSubscriptionPackageWithAllocation.validity() - - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = newSubscriptionTierWithProration.validity() - - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = newSubscriptionUnitWithProration.validity() - - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = newSubscriptionGroupedAllocation.validity() - - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = newSubscriptionGroupedWithProratedMinimum.validity() - - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = newSubscriptionBulkWithProration.validity() - - override fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = newSubscriptionScalableMatrixWithUnitPricing.validity() - - override fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = newSubscriptionScalableMatrixWithTieredPricing.validity() - - override fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice - ) = newSubscriptionCumulativeGroupedBulk.validity() - - override fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice - ) = newSubscriptionMaxGroupTieredPackage.validity() - - override fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = newSubscriptionGroupedWithMeteredMinimum.validity() - - override fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice - ) = newSubscriptionMatrixWithDisplayName.validity() - - override fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice - ) = newSubscriptionGroupedTieredPackage.validity() + override fun 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 visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() + + override fun visitBulk(bulk: Bulk) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -8751,215 +7770,141 @@ private constructor( return true } - return /* spotless:off */ other is Price && newSubscriptionUnit == other.newSubscriptionUnit && newSubscriptionPackage == other.newSubscriptionPackage && newSubscriptionMatrix == other.newSubscriptionMatrix && newSubscriptionTiered == other.newSubscriptionTiered && newSubscriptionTieredBps == other.newSubscriptionTieredBps && newSubscriptionBps == other.newSubscriptionBps && newSubscriptionBulkBps == other.newSubscriptionBulkBps && newSubscriptionBulk == other.newSubscriptionBulk && newSubscriptionThresholdTotalAmount == other.newSubscriptionThresholdTotalAmount && newSubscriptionTieredPackage == other.newSubscriptionTieredPackage && newSubscriptionTieredWithMinimum == other.newSubscriptionTieredWithMinimum && newSubscriptionUnitWithPercent == other.newSubscriptionUnitWithPercent && newSubscriptionPackageWithAllocation == other.newSubscriptionPackageWithAllocation && newSubscriptionTierWithProration == other.newSubscriptionTierWithProration && newSubscriptionUnitWithProration == other.newSubscriptionUnitWithProration && newSubscriptionGroupedAllocation == other.newSubscriptionGroupedAllocation && newSubscriptionGroupedWithProratedMinimum == other.newSubscriptionGroupedWithProratedMinimum && newSubscriptionBulkWithProration == other.newSubscriptionBulkWithProration && newSubscriptionScalableMatrixWithUnitPricing == other.newSubscriptionScalableMatrixWithUnitPricing && newSubscriptionScalableMatrixWithTieredPricing == other.newSubscriptionScalableMatrixWithTieredPricing && newSubscriptionCumulativeGroupedBulk == other.newSubscriptionCumulativeGroupedBulk && newSubscriptionMaxGroupTieredPackage == other.newSubscriptionMaxGroupTieredPackage && newSubscriptionGroupedWithMeteredMinimum == other.newSubscriptionGroupedWithMeteredMinimum && newSubscriptionMatrixWithDisplayName == other.newSubscriptionMatrixWithDisplayName && newSubscriptionGroupedTieredPackage == other.newSubscriptionGroupedTieredPackage /* spotless:on */ + 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 /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newSubscriptionUnit, newSubscriptionPackage, newSubscriptionMatrix, newSubscriptionTiered, newSubscriptionTieredBps, newSubscriptionBps, newSubscriptionBulkBps, newSubscriptionBulk, newSubscriptionThresholdTotalAmount, newSubscriptionTieredPackage, newSubscriptionTieredWithMinimum, newSubscriptionUnitWithPercent, newSubscriptionPackageWithAllocation, newSubscriptionTierWithProration, newSubscriptionUnitWithProration, newSubscriptionGroupedAllocation, newSubscriptionGroupedWithProratedMinimum, newSubscriptionBulkWithProration, newSubscriptionScalableMatrixWithUnitPricing, newSubscriptionScalableMatrixWithTieredPricing, newSubscriptionCumulativeGroupedBulk, newSubscriptionMaxGroupTieredPackage, newSubscriptionGroupedWithMeteredMinimum, newSubscriptionMatrixWithDisplayName, newSubscriptionGroupedTieredPackage) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, bulkWithProration, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, maxGroupTieredPackage, groupedWithMeteredMinimum, matrixWithDisplayName, groupedTieredPackage) /* spotless:on */ override fun toString(): String = when { - newSubscriptionUnit != null -> "Price{newSubscriptionUnit=$newSubscriptionUnit}" - newSubscriptionPackage != null -> - "Price{newSubscriptionPackage=$newSubscriptionPackage}" - newSubscriptionMatrix != null -> - "Price{newSubscriptionMatrix=$newSubscriptionMatrix}" - newSubscriptionTiered != null -> - "Price{newSubscriptionTiered=$newSubscriptionTiered}" - newSubscriptionTieredBps != null -> - "Price{newSubscriptionTieredBps=$newSubscriptionTieredBps}" - newSubscriptionBps != null -> "Price{newSubscriptionBps=$newSubscriptionBps}" - newSubscriptionBulkBps != null -> - "Price{newSubscriptionBulkBps=$newSubscriptionBulkBps}" - newSubscriptionBulk != null -> "Price{newSubscriptionBulk=$newSubscriptionBulk}" - newSubscriptionThresholdTotalAmount != null -> - "Price{newSubscriptionThresholdTotalAmount=$newSubscriptionThresholdTotalAmount}" - newSubscriptionTieredPackage != null -> - "Price{newSubscriptionTieredPackage=$newSubscriptionTieredPackage}" - newSubscriptionTieredWithMinimum != null -> - "Price{newSubscriptionTieredWithMinimum=$newSubscriptionTieredWithMinimum}" - newSubscriptionUnitWithPercent != null -> - "Price{newSubscriptionUnitWithPercent=$newSubscriptionUnitWithPercent}" - newSubscriptionPackageWithAllocation != null -> - "Price{newSubscriptionPackageWithAllocation=$newSubscriptionPackageWithAllocation}" - newSubscriptionTierWithProration != null -> - "Price{newSubscriptionTierWithProration=$newSubscriptionTierWithProration}" - newSubscriptionUnitWithProration != null -> - "Price{newSubscriptionUnitWithProration=$newSubscriptionUnitWithProration}" - newSubscriptionGroupedAllocation != null -> - "Price{newSubscriptionGroupedAllocation=$newSubscriptionGroupedAllocation}" - newSubscriptionGroupedWithProratedMinimum != null -> - "Price{newSubscriptionGroupedWithProratedMinimum=$newSubscriptionGroupedWithProratedMinimum}" - newSubscriptionBulkWithProration != null -> - "Price{newSubscriptionBulkWithProration=$newSubscriptionBulkWithProration}" - newSubscriptionScalableMatrixWithUnitPricing != null -> - "Price{newSubscriptionScalableMatrixWithUnitPricing=$newSubscriptionScalableMatrixWithUnitPricing}" - newSubscriptionScalableMatrixWithTieredPricing != null -> - "Price{newSubscriptionScalableMatrixWithTieredPricing=$newSubscriptionScalableMatrixWithTieredPricing}" - newSubscriptionCumulativeGroupedBulk != null -> - "Price{newSubscriptionCumulativeGroupedBulk=$newSubscriptionCumulativeGroupedBulk}" - newSubscriptionMaxGroupTieredPackage != null -> - "Price{newSubscriptionMaxGroupTieredPackage=$newSubscriptionMaxGroupTieredPackage}" - newSubscriptionGroupedWithMeteredMinimum != null -> - "Price{newSubscriptionGroupedWithMeteredMinimum=$newSubscriptionGroupedWithMeteredMinimum}" - newSubscriptionMatrixWithDisplayName != null -> - "Price{newSubscriptionMatrixWithDisplayName=$newSubscriptionMatrixWithDisplayName}" - newSubscriptionGroupedTieredPackage != null -> - "Price{newSubscriptionGroupedTieredPackage=$newSubscriptionGroupedTieredPackage}" + 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}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } companion object { + @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 ofBulkBps(bulkBps: BulkBps) = Price(bulkBps = bulkBps) + + @JvmStatic fun ofBulk(bulk: Bulk) = Price(bulk = bulk) + @JvmStatic - fun ofNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice) = - Price(newSubscriptionUnit = newSubscriptionUnit) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + Price(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofNewSubscriptionPackage(newSubscriptionPackage: NewSubscriptionPackagePrice) = - Price(newSubscriptionPackage = newSubscriptionPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + Price(tieredPackage = tieredPackage) @JvmStatic - fun ofNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice) = - Price(newSubscriptionMatrix = newSubscriptionMatrix) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice) = - Price(newSubscriptionTiered = newSubscriptionTiered) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + Price(unitWithPercent = unitWithPercent) @JvmStatic - fun ofNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = Price(newSubscriptionTieredBps = newSubscriptionTieredBps) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice) = - Price(newSubscriptionBps = newSubscriptionBps) + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) @JvmStatic - fun ofNewSubscriptionBulkBps(newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice) = - Price(newSubscriptionBulkBps = newSubscriptionBulkBps) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + Price(unitWithProration = unitWithProration) @JvmStatic - fun ofNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice) = - Price(newSubscriptionBulk = newSubscriptionBulk) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + Price(groupedAllocation = groupedAllocation) @JvmStatic - fun ofNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(newSubscriptionThresholdTotalAmount = newSubscriptionThresholdTotalAmount) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = Price(newSubscriptionTieredPackage = newSubscriptionTieredPackage) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + Price(bulkWithProration = bulkWithProration) @JvmStatic - fun ofNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = Price(newSubscriptionTieredWithMinimum = newSubscriptionTieredWithMinimum) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic - fun ofNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = Price(newSubscriptionUnitWithPercent = newSubscriptionUnitWithPercent) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = - Price( - newSubscriptionPackageWithAllocation = newSubscriptionPackageWithAllocation - ) - - @JvmStatic - fun ofNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(newSubscriptionTierWithProration = newSubscriptionTierWithProration) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + Price(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic - fun ofNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = Price(newSubscriptionUnitWithProration = newSubscriptionUnitWithProration) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + Price(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic - fun ofNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = Price(newSubscriptionGroupedAllocation = newSubscriptionGroupedAllocation) + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = - Price( - newSubscriptionGroupedWithProratedMinimum = - newSubscriptionGroupedWithProratedMinimum - ) - - @JvmStatic - fun ofNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = Price(newSubscriptionBulkWithProration = newSubscriptionBulkWithProration) - - @JvmStatic - fun ofNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = - Price( - newSubscriptionScalableMatrixWithUnitPricing = - newSubscriptionScalableMatrixWithUnitPricing - ) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = - Price( - newSubscriptionScalableMatrixWithTieredPricing = - newSubscriptionScalableMatrixWithTieredPricing - ) - - @JvmStatic - fun ofNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = - Price( - newSubscriptionCumulativeGroupedBulk = newSubscriptionCumulativeGroupedBulk - ) - - @JvmStatic - fun ofNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = - Price( - newSubscriptionMaxGroupTieredPackage = newSubscriptionMaxGroupTieredPackage - ) - - @JvmStatic - fun ofNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = - Price( - newSubscriptionGroupedWithMeteredMinimum = - newSubscriptionGroupedWithMeteredMinimum - ) - - @JvmStatic - fun ofNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = - Price( - newSubscriptionMatrixWithDisplayName = newSubscriptionMatrixWithDisplayName - ) - - @JvmStatic - fun ofNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(newSubscriptionGroupedTieredPackage = newSubscriptionGroupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + Price(groupedTieredPackage = groupedTieredPackage) } /** @@ -8967,99 +7912,63 @@ private constructor( */ interface Visitor { - fun visitNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ): T + fun visitPackage(package_: Package): T - fun visitNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ): T + fun visitTieredBps(tieredBps: TieredBps): T - fun visitNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice): T + fun visitBps(bps: Bps): T - fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ): T + fun visitBulkBps(bulkBps: BulkBps): T - fun visitNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice): T + fun visitBulk(bulk: Bulk): T - fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T - fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T - fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T - fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T - fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T - fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T - fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -9085,221 +7994,138 @@ private constructor( when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionUnit = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(package_ = it, _json = json) + } ?: Price(_json = json) } "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionMatrix = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) } "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } "tiered_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredBps = it, _json = json) + } ?: Price(_json = json) } "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bps = it, _json = json) + } ?: Price(_json = json) } "bulk_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionBulkBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkBps = it, _json = json) + } ?: Price(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionThresholdTotalAmount = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) } "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredPackage = it, _json = json) + } ?: Price(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredWithMinimum = it, _json = json) + } ?: Price(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionUnitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithPercent = it, _json = json) + } ?: Price(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionPackageWithAllocation = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) } "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTierWithProration = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionUnitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedAllocation = it, _json = json) + } ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionBulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithProration = it, _json = json) + } ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionScalableMatrixWithUnitPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionScalableMatrixWithTieredPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionCumulativeGroupedBulk = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionMaxGroupTieredPackage = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price( - newSubscriptionGroupedWithMeteredMinimum = it, - _json = json, - ) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionMatrixWithDisplayName = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionGroupedTieredPackage = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } } @@ -9315,71 +8141,58 @@ private constructor( provider: SerializerProvider, ) { when { - value.newSubscriptionUnit != null -> - generator.writeObject(value.newSubscriptionUnit) - value.newSubscriptionPackage != null -> - generator.writeObject(value.newSubscriptionPackage) - value.newSubscriptionMatrix != null -> - generator.writeObject(value.newSubscriptionMatrix) - value.newSubscriptionTiered != null -> - generator.writeObject(value.newSubscriptionTiered) - value.newSubscriptionTieredBps != null -> - generator.writeObject(value.newSubscriptionTieredBps) - value.newSubscriptionBps != null -> - generator.writeObject(value.newSubscriptionBps) - value.newSubscriptionBulkBps != null -> - generator.writeObject(value.newSubscriptionBulkBps) - value.newSubscriptionBulk != null -> - generator.writeObject(value.newSubscriptionBulk) - value.newSubscriptionThresholdTotalAmount != null -> - generator.writeObject(value.newSubscriptionThresholdTotalAmount) - value.newSubscriptionTieredPackage != null -> - generator.writeObject(value.newSubscriptionTieredPackage) - value.newSubscriptionTieredWithMinimum != null -> - generator.writeObject(value.newSubscriptionTieredWithMinimum) - value.newSubscriptionUnitWithPercent != null -> - generator.writeObject(value.newSubscriptionUnitWithPercent) - value.newSubscriptionPackageWithAllocation != null -> - generator.writeObject(value.newSubscriptionPackageWithAllocation) - value.newSubscriptionTierWithProration != null -> - generator.writeObject(value.newSubscriptionTierWithProration) - value.newSubscriptionUnitWithProration != null -> - generator.writeObject(value.newSubscriptionUnitWithProration) - value.newSubscriptionGroupedAllocation != null -> - generator.writeObject(value.newSubscriptionGroupedAllocation) - value.newSubscriptionGroupedWithProratedMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithProratedMinimum) - value.newSubscriptionBulkWithProration != null -> - generator.writeObject(value.newSubscriptionBulkWithProration) - value.newSubscriptionScalableMatrixWithUnitPricing != null -> - generator.writeObject( - value.newSubscriptionScalableMatrixWithUnitPricing - ) - value.newSubscriptionScalableMatrixWithTieredPricing != null -> - generator.writeObject( - value.newSubscriptionScalableMatrixWithTieredPricing - ) - value.newSubscriptionCumulativeGroupedBulk != null -> - generator.writeObject(value.newSubscriptionCumulativeGroupedBulk) - value.newSubscriptionMaxGroupTieredPackage != null -> - generator.writeObject(value.newSubscriptionMaxGroupTieredPackage) - value.newSubscriptionGroupedWithMeteredMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithMeteredMinimum) - value.newSubscriptionMatrixWithDisplayName != null -> - generator.writeObject(value.newSubscriptionMatrixWithDisplayName) - value.newSubscriptionGroupedTieredPackage != null -> - generator.writeObject(value.newSubscriptionGroupedTieredPackage) + 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._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - class NewSubscriptionUnitPrice + class Unit private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitConfig: JsonField, private val billableMetricId: JsonField, @@ -9406,7 +8219,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -9487,11 +8300,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -9632,16 +8449,6 @@ private constructor( */ @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]. * @@ -9787,14 +8594,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitPrice]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` @@ -9802,12 +8607,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitPrice]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -9827,27 +8632,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionUnitPrice: NewSubscriptionUnitPrice) = apply { - cadence = newSubscriptionUnitPrice.cadence - itemId = newSubscriptionUnitPrice.itemId - modelType = newSubscriptionUnitPrice.modelType - name = newSubscriptionUnitPrice.name - unitConfig = newSubscriptionUnitPrice.unitConfig - billableMetricId = newSubscriptionUnitPrice.billableMetricId - billedInAdvance = newSubscriptionUnitPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitPrice.conversionRate - currency = newSubscriptionUnitPrice.currency - externalPriceId = newSubscriptionUnitPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitPrice.metadata - referenceId = newSubscriptionUnitPrice.referenceId - additionalProperties = - newSubscriptionUnitPrice.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + currency = unit.currency + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -9874,18 +8676,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -10219,7 +9022,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitPrice]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -10227,18 +9030,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitPrice = - NewSubscriptionUnitPrice( + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitConfig", unitConfig), billableMetricId, @@ -10258,14 +9060,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitPrice = apply { + fun validate(): Unit = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitConfig().validate() billableMetricId() @@ -10300,7 +9106,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -10474,135 +9280,6 @@ private constructor( 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 UNIT = of("unit") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT - } - - /** - * 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 { - UNIT, - /** - * 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) { - UNIT -> Value.UNIT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT -> Known.UNIT - 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 UnitConfig private constructor( private val unitAmount: JsonField, @@ -11612,7 +10289,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Unit && 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 && currency == other.currency && 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 */ @@ -11622,14 +10299,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionPackagePrice + class Package private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageConfig: JsonField, private val billableMetricId: JsonField, @@ -11656,7 +10333,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -11737,11 +10414,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -11882,16 +10563,6 @@ private constructor( */ @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]. * @@ -12037,14 +10708,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionPackagePrice]. + * Returns a mutable builder for constructing an instance of [Package]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` @@ -12052,12 +10721,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionPackagePrice]. */ + /** A builder for [Package]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package") private var name: JsonField? = null private var packageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -12077,29 +10746,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionPackagePrice: NewSubscriptionPackagePrice) = - apply { - cadence = newSubscriptionPackagePrice.cadence - itemId = newSubscriptionPackagePrice.itemId - modelType = newSubscriptionPackagePrice.modelType - name = newSubscriptionPackagePrice.name - packageConfig = newSubscriptionPackagePrice.packageConfig - billableMetricId = newSubscriptionPackagePrice.billableMetricId - billedInAdvance = newSubscriptionPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionPackagePrice.conversionRate - currency = newSubscriptionPackagePrice.currency - externalPriceId = newSubscriptionPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionPackagePrice.metadata - referenceId = newSubscriptionPackagePrice.referenceId - additionalProperties = - newSubscriptionPackagePrice.additionalProperties.toMutableMap() - } + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + currency = package_.currency + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -12125,18 +10790,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -12471,7 +11137,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionPackagePrice]. + * Returns an immutable instance of [Package]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -12479,18 +11145,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionPackagePrice = - NewSubscriptionPackagePrice( + fun build(): Package = + Package( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageConfig", packageConfig), billableMetricId, @@ -12510,14 +11175,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionPackagePrice = apply { + fun validate(): Package = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageConfig().validate() billableMetricId() @@ -12552,7 +11221,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -12726,135 +11395,6 @@ private constructor( 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 PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * 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 { - PACKAGE, - /** - * 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) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - 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 PackageConfig private constructor( private val packageAmount: JsonField, @@ -13915,7 +12455,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Package && 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 && currency == other.currency && 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 */ @@ -13925,15 +12465,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Package{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMatrixPrice + class Matrix private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -13962,7 +12502,7 @@ private constructor( matrixConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -14047,11 +12587,15 @@ private constructor( fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -14195,16 +12739,6 @@ private constructor( @ExcludeMissing fun _matrixConfig(): JsonField = matrixConfig - /** - * 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]. * @@ -14340,28 +12874,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMatrixPrice]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMatrixPrice]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -14380,29 +12912,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionMatrixPrice: NewSubscriptionMatrixPrice) = - apply { - cadence = newSubscriptionMatrixPrice.cadence - itemId = newSubscriptionMatrixPrice.itemId - matrixConfig = newSubscriptionMatrixPrice.matrixConfig - modelType = newSubscriptionMatrixPrice.modelType - name = newSubscriptionMatrixPrice.name - billableMetricId = newSubscriptionMatrixPrice.billableMetricId - billedInAdvance = newSubscriptionMatrixPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixPrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixPrice.conversionRate - currency = newSubscriptionMatrixPrice.currency - externalPriceId = newSubscriptionMatrixPrice.externalPriceId - fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionMatrixPrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixPrice.metadata - referenceId = newSubscriptionMatrixPrice.referenceId - additionalProperties = - newSubscriptionMatrixPrice.additionalProperties.toMutableMap() - } + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + currency = matrix.currency + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -14442,18 +12970,19 @@ private constructor( this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -14774,7 +13303,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMatrixPrice]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -14783,18 +13312,17 @@ private constructor( * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMatrixPrice = - NewSubscriptionMatrixPrice( + fun build(): Matrix = + Matrix( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -14813,7 +13341,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMatrixPrice = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -14821,7 +13349,11 @@ private constructor( cadence().validate() itemId() matrixConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -14856,7 +13388,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -15574,135 +14106,6 @@ private constructor( "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -16541,7 +14944,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Matrix && 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 && currency == other.currency && 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 */ @@ -16551,14 +14954,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Matrix{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredPrice + class Tiered private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredConfig: JsonField, private val billableMetricId: JsonField, @@ -16585,7 +14988,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -16666,11 +15069,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -16811,16 +15218,6 @@ private constructor( */ @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]. * @@ -16966,14 +15363,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredPrice]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` @@ -16981,12 +15376,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredPrice]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered") private var name: JsonField? = null private var tieredConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -17006,29 +15401,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionTieredPrice: NewSubscriptionTieredPrice) = - apply { - cadence = newSubscriptionTieredPrice.cadence - itemId = newSubscriptionTieredPrice.itemId - modelType = newSubscriptionTieredPrice.modelType - name = newSubscriptionTieredPrice.name - tieredConfig = newSubscriptionTieredPrice.tieredConfig - billableMetricId = newSubscriptionTieredPrice.billableMetricId - billedInAdvance = newSubscriptionTieredPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPrice.conversionRate - currency = newSubscriptionTieredPrice.currency - externalPriceId = newSubscriptionTieredPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPrice.metadata - referenceId = newSubscriptionTieredPrice.referenceId - additionalProperties = - newSubscriptionTieredPrice.additionalProperties.toMutableMap() - } + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + currency = tiered.currency + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -17054,18 +15445,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -17400,7 +15792,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredPrice]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -17408,18 +15800,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredPrice = - NewSubscriptionTieredPrice( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredConfig", tieredConfig), billableMetricId, @@ -17439,14 +15830,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredPrice = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredConfig().validate() billableMetricId() @@ -17481,7 +15876,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -17655,135 +16050,6 @@ private constructor( 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 = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * 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, - /** - * 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 -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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 -> Known.TIERED - 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 TieredConfig private constructor( private val tiers: JsonField>, @@ -19085,7 +17351,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tiered && 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 && currency == other.currency && 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 */ @@ -19095,14 +17361,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredBpsPrice + class TieredBps private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredBpsConfig: JsonField, private val billableMetricId: JsonField, @@ -19129,7 +17395,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -19210,11 +17476,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -19356,16 +17626,6 @@ private constructor( */ @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]. * @@ -19511,14 +17771,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredBpsPrice]. + * Returns a mutable builder for constructing an instance of [TieredBps]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` @@ -19526,12 +17784,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredBpsPrice]. */ + /** A builder for [TieredBps]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_bps") private var name: JsonField? = null private var tieredBpsConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -19551,29 +17809,24 @@ private constructor( 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 - currency = newSubscriptionTieredBpsPrice.currency - externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredBpsPrice.metadata - referenceId = newSubscriptionTieredBpsPrice.referenceId - additionalProperties = - newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() + internal fun from(tieredBps: TieredBps) = apply { + cadence = tieredBps.cadence + itemId = tieredBps.itemId + modelType = tieredBps.modelType + name = tieredBps.name + tieredBpsConfig = tieredBps.tieredBpsConfig + billableMetricId = tieredBps.billableMetricId + billedInAdvance = tieredBps.billedInAdvance + billingCycleConfiguration = tieredBps.billingCycleConfiguration + conversionRate = tieredBps.conversionRate + currency = tieredBps.currency + externalPriceId = tieredBps.externalPriceId + fixedPriceQuantity = tieredBps.fixedPriceQuantity + invoiceGroupingKey = tieredBps.invoiceGroupingKey + invoicingCycleConfiguration = tieredBps.invoicingCycleConfiguration + metadata = tieredBps.metadata + referenceId = tieredBps.referenceId + additionalProperties = tieredBps.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -19600,18 +17853,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -19946,7 +18200,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredBpsPrice]. + * Returns an immutable instance of [TieredBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -19954,18 +18208,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice( + fun build(): TieredBps = + TieredBps( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredBpsConfig", tieredBpsConfig), billableMetricId, @@ -19985,14 +18238,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredBpsPrice = apply { + fun validate(): TieredBps = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredBpsConfig().validate() billableMetricId() @@ -20027,7 +18284,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -20201,135 +18458,6 @@ private constructor( 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() - } - class TieredBpsConfig private constructor( private val tiers: JsonField>, @@ -21673,7 +19801,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBps && 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 && currency == other.currency && 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 */ @@ -21683,15 +19811,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredBps{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBpsPrice + class Bps private constructor( private val bpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -21720,7 +19848,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -21805,11 +19933,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -21953,16 +20085,6 @@ private constructor( */ @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]. * @@ -22098,28 +20220,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBpsPrice]. + * Returns a mutable builder for constructing an instance of [Bps]. * * The following fields are required: * ```java * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBpsPrice]. */ + /** A builder for [Bps]. */ 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 modelType: JsonValue = JsonValue.from("bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -22138,27 +20258,24 @@ private constructor( 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 - currency = newSubscriptionBpsPrice.currency - externalPriceId = newSubscriptionBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBpsPrice.metadata - referenceId = newSubscriptionBpsPrice.referenceId - additionalProperties = - newSubscriptionBpsPrice.additionalProperties.toMutableMap() + internal fun from(bps: Bps) = apply { + bpsConfig = bps.bpsConfig + cadence = bps.cadence + itemId = bps.itemId + modelType = bps.modelType + name = bps.name + billableMetricId = bps.billableMetricId + billedInAdvance = bps.billedInAdvance + billingCycleConfiguration = bps.billingCycleConfiguration + conversionRate = bps.conversionRate + currency = bps.currency + externalPriceId = bps.externalPriceId + fixedPriceQuantity = bps.fixedPriceQuantity + invoiceGroupingKey = bps.invoiceGroupingKey + invoicingCycleConfiguration = bps.invoicingCycleConfiguration + metadata = bps.metadata + referenceId = bps.referenceId + additionalProperties = bps.additionalProperties.toMutableMap() } fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) @@ -22198,18 +20315,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -22530,7 +20648,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBpsPrice]. + * Returns an immutable instance of [Bps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -22539,18 +20657,17 @@ private constructor( * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBpsPrice = - NewSubscriptionBpsPrice( + fun build(): Bps = + Bps( checkRequired("bpsConfig", bpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -22569,7 +20686,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBpsPrice = apply { + fun validate(): Bps = apply { if (validated) { return@apply } @@ -22577,7 +20694,11 @@ private constructor( bpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -22612,7 +20733,7 @@ private constructor( (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -23003,135 +21124,6 @@ private constructor( 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -23970,7 +21962,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bps && 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 && currency == other.currency && 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 */ @@ -23980,15 +21972,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bps{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkBpsPrice + class BulkBps private constructor( private val bulkBpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -24017,7 +22009,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -24102,11 +22094,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -24250,16 +22246,6 @@ private constructor( */ @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]. * @@ -24395,28 +22381,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of [BulkBps]. * * The following fields are required: * ```java * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkBpsPrice]. */ + /** A builder for [BulkBps]. */ class Builder internal constructor() { private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -24435,29 +22419,25 @@ 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 - currency = newSubscriptionBulkBpsPrice.currency - externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkBpsPrice.metadata - referenceId = newSubscriptionBulkBpsPrice.referenceId - additionalProperties = - newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() - } + internal fun from(bulkBps: BulkBps) = apply { + bulkBpsConfig = bulkBps.bulkBpsConfig + cadence = bulkBps.cadence + itemId = bulkBps.itemId + modelType = bulkBps.modelType + name = bulkBps.name + billableMetricId = bulkBps.billableMetricId + billedInAdvance = bulkBps.billedInAdvance + billingCycleConfiguration = bulkBps.billingCycleConfiguration + conversionRate = bulkBps.conversionRate + currency = bulkBps.currency + externalPriceId = bulkBps.externalPriceId + fixedPriceQuantity = bulkBps.fixedPriceQuantity + invoiceGroupingKey = bulkBps.invoiceGroupingKey + invoicingCycleConfiguration = bulkBps.invoicingCycleConfiguration + metadata = bulkBps.metadata + referenceId = bulkBps.referenceId + additionalProperties = bulkBps.additionalProperties.toMutableMap() + } fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = bulkBpsConfig(JsonField.of(bulkBpsConfig)) @@ -24497,18 +22477,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -24829,7 +22810,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkBpsPrice]. + * Returns an immutable instance of [BulkBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -24838,18 +22819,17 @@ private constructor( * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( + fun build(): BulkBps = + BulkBps( checkRequired("bulkBpsConfig", bulkBpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -24868,7 +22848,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkBpsPrice = apply { + fun validate(): BulkBps = apply { if (validated) { return@apply } @@ -24876,7 +22856,11 @@ private constructor( bulkBpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -24911,7 +22895,7 @@ private constructor( (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -25543,135 +23527,6 @@ private constructor( 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 BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -26510,7 +24365,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBps && 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 && currency == other.currency && 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 */ @@ -26520,15 +24375,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkBps{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkPrice + class Bulk private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -26557,7 +24412,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -26642,11 +24497,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -26790,16 +24649,6 @@ private constructor( */ @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]. * @@ -26935,28 +24784,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkPrice]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkPrice]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -26975,27 +24822,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionBulkPrice: NewSubscriptionBulkPrice) = apply { - bulkConfig = newSubscriptionBulkPrice.bulkConfig - cadence = newSubscriptionBulkPrice.cadence - itemId = newSubscriptionBulkPrice.itemId - modelType = newSubscriptionBulkPrice.modelType - name = newSubscriptionBulkPrice.name - billableMetricId = newSubscriptionBulkPrice.billableMetricId - billedInAdvance = newSubscriptionBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkPrice.conversionRate - currency = newSubscriptionBulkPrice.currency - externalPriceId = newSubscriptionBulkPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkPrice.metadata - referenceId = newSubscriptionBulkPrice.referenceId - additionalProperties = - newSubscriptionBulkPrice.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + currency = bulk.currency + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() } fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) @@ -27035,18 +24879,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -27367,7 +25212,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkPrice]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -27376,18 +25221,17 @@ private constructor( * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkPrice = - NewSubscriptionBulkPrice( + fun build(): Bulk = + Bulk( checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -27406,7 +25250,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkPrice = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -27414,7 +25258,11 @@ private constructor( bulkConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -27449,7 +25297,7 @@ private constructor( (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -28039,135 +25887,6 @@ private constructor( 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 BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -29006,7 +26725,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bulk && 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 && currency == other.currency && 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 */ @@ -29016,14 +26735,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionThresholdTotalAmountPrice + class ThresholdTotalAmount private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val thresholdTotalAmountConfig: JsonField, private val billableMetricId: JsonField, @@ -29050,7 +26769,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -29132,11 +26851,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -29278,16 +27001,6 @@ private constructor( */ @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]. * @@ -29435,13 +27148,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionThresholdTotalAmountPrice]. + * [ThresholdTotalAmount]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` @@ -29449,12 +27161,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionThresholdTotalAmountPrice]. */ + /** A builder for [ThresholdTotalAmount]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") private var name: JsonField? = null private var thresholdTotalAmountConfig: JsonField? = null @@ -29475,34 +27187,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionThresholdTotalAmountPrice: - NewSubscriptionThresholdTotalAmountPrice - ) = apply { - cadence = newSubscriptionThresholdTotalAmountPrice.cadence - itemId = newSubscriptionThresholdTotalAmountPrice.itemId - modelType = newSubscriptionThresholdTotalAmountPrice.modelType - name = newSubscriptionThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newSubscriptionThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newSubscriptionThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newSubscriptionThresholdTotalAmountPrice.conversionRate - currency = newSubscriptionThresholdTotalAmountPrice.currency - externalPriceId = newSubscriptionThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + currency = thresholdTotalAmount.currency + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newSubscriptionThresholdTotalAmountPrice.metadata - referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId + thresholdTotalAmount.invoicingCycleConfiguration + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId additionalProperties = - newSubscriptionThresholdTotalAmountPrice.additionalProperties - .toMutableMap() + thresholdTotalAmount.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -29529,18 +27233,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -29877,7 +27582,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionThresholdTotalAmountPrice]. + * Returns an immutable instance of [ThresholdTotalAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -29885,18 +27590,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionThresholdTotalAmountPrice = - NewSubscriptionThresholdTotalAmountPrice( + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), billableMetricId, @@ -29916,14 +27620,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -29958,7 +27666,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -30132,135 +27842,6 @@ private constructor( 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 THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * 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 { - THRESHOLD_TOTAL_AMOUNT, - /** - * 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) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - 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 ThresholdTotalAmountConfig @JsonCreator private constructor( @@ -31213,7 +28794,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmount && 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 && currency == other.currency && 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 */ @@ -31223,14 +28804,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredPackagePrice + class TieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredPackageConfig: JsonField, private val billableMetricId: JsonField, @@ -31257,7 +28838,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -31338,11 +28919,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -31484,16 +29069,6 @@ private constructor( */ @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]. * @@ -31639,14 +29214,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [TieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` @@ -31654,12 +29227,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredPackagePrice]. */ + /** A builder for [TieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_package") private var name: JsonField? = null private var tieredPackageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -31679,29 +29252,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionTieredPackagePrice: NewSubscriptionTieredPackagePrice - ) = apply { - cadence = newSubscriptionTieredPackagePrice.cadence - itemId = newSubscriptionTieredPackagePrice.itemId - modelType = newSubscriptionTieredPackagePrice.modelType - name = newSubscriptionTieredPackagePrice.name - tieredPackageConfig = newSubscriptionTieredPackagePrice.tieredPackageConfig - billableMetricId = newSubscriptionTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPackagePrice.conversionRate - currency = newSubscriptionTieredPackagePrice.currency - externalPriceId = newSubscriptionTieredPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPackagePrice.metadata - referenceId = newSubscriptionTieredPackagePrice.referenceId - additionalProperties = - newSubscriptionTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + currency = tieredPackage.currency + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -31728,18 +29296,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -32075,7 +29644,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredPackagePrice]. + * Returns an immutable instance of [TieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -32083,18 +29652,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredPackagePrice = - NewSubscriptionTieredPackagePrice( + fun build(): TieredPackage = + TieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredPackageConfig", tieredPackageConfig), billableMetricId, @@ -32114,14 +29682,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredPackagePrice = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredPackageConfig().validate() billableMetricId() @@ -32156,7 +29728,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -32330,102 +29902,78 @@ private constructor( override fun toString() = value.toString() } - class ModelType + class TieredPackageConfig @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ + private constructor( @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { + private val additionalProperties: Map + ) { - @JvmField val TIERED_PACKAGE = of("tiered_package") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } + fun toBuilder() = Builder().from(this) - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } + companion object { - /** - * 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_PACKAGE, /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. + * Returns a mutable builder for constructing an instance of + * [TieredPackageConfig]. */ - _UNKNOWN, + @JvmStatic fun builder() = Builder() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN + /** A builder for [TieredPackageConfig]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { + additionalProperties = + tieredPackageConfig.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_PACKAGE -> Known.TIERED_PACKAGE - else -> throw OrbInvalidDataException("Unknown ModelType: $value") + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + 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) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [TieredPackageConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TieredPackageConfig = + TieredPackageConfig(additionalProperties.toImmutable()) + } + private var validated: Boolean = false - fun validate(): ModelType = apply { + fun validate(): TieredPackageConfig = apply { if (validated) { return@apply } - known() validated = true } @@ -32444,31 +29992,97 @@ private constructor( * Used for best match union deserialization. */ @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is ModelType && value == other.value /* spotless:on */ + return /* spotless:off */ other is TieredPackageConfig && additionalProperties == other.additionalProperties /* spotless:on */ } - override fun hashCode() = value.hashCode() + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ - override fun toString() = value.toString() + override fun hashCode(): Int = hashCode + + override fun toString() = + "TieredPackageConfig{additionalProperties=$additionalProperties}" } - class TieredPackageConfig - @JsonCreator + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + class BillingCycleConfiguration private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map + private val duration: JsonField, + private val durationUnit: JsonField, + private val additionalProperties: MutableMap, ) { + @JsonCreator + private constructor( + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + durationUnit: JsonField = JsonMissing.of(), + ) : this(duration, durationUnit, mutableMapOf()) + + /** + * The duration of the billing 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 duration(): Long = duration.getRequired("duration") + + /** + * The unit of billing period duration. + * + * @throws OrbInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [durationUnit]. + * + * Unlike [durationUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit + + @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) @@ -32476,230 +30090,59 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [TieredPackageConfig]. + * [BillingCycleConfiguration]. + * + * The following fields are required: + * ```java + * .duration() + * .durationUnit() + * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [TieredPackageConfig]. */ + /** A builder for [BillingCycleConfiguration]. */ class Builder internal constructor() { + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tieredPackageConfig: TieredPackageConfig) = apply { - additionalProperties = - tieredPackageConfig.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TieredPackageConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TieredPackageConfig = - TieredPackageConfig(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): TieredPackageConfig = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @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 TieredPackageConfig && 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() = - "TieredPackageConfig{additionalProperties=$additionalProperties}" - } - - /** - * For custom cadence: specifies the duration of the billing period in days or - * months. - */ - class BillingCycleConfiguration - private constructor( - private val duration: JsonField, - private val durationUnit: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("duration_unit") - @ExcludeMissing - durationUnit: JsonField = JsonMissing.of(), - ) : this(duration, durationUnit, mutableMapOf()) - - /** - * The duration of the billing 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 duration(): Long = duration.getRequired("duration") - - /** - * The unit of billing period duration. - * - * @throws OrbInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** - * Returns the raw JSON value of [durationUnit]. - * - * Unlike [durationUnit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("duration_unit") - @ExcludeMissing - fun _durationUnit(): JsonField = durationUnit - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BillingCycleConfiguration]. - * - * The following fields are required: - * ```java - * .duration() - * .durationUnit() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BillingCycleConfiguration]. */ - class Builder internal constructor() { - - private var duration: JsonField? = null - private var durationUnit: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = - apply { - duration = billingCycleConfiguration.duration - durationUnit = billingCycleConfiguration.durationUnit - additionalProperties = - billingCycleConfiguration.additionalProperties.toMutableMap() - } - - /** The duration of the billing period. */ - fun duration(duration: Long) = duration(JsonField.of(duration)) - - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = - durationUnit(JsonField.of(durationUnit)) - - /** - * Sets [Builder.durationUnit] to an arbitrary JSON value. - * - * You should usually call [Builder.durationUnit] with a well-typed - * [DurationUnit] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun durationUnit(durationUnit: JsonField) = apply { - this.durationUnit = durationUnit + internal fun from(billingCycleConfiguration: BillingCycleConfiguration) = + apply { + duration = billingCycleConfiguration.duration + durationUnit = billingCycleConfiguration.durationUnit + additionalProperties = + billingCycleConfiguration.additionalProperties.toMutableMap() + } + + /** The duration of the billing period. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** + * Sets [Builder.durationUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.durationUnit] with a well-typed + * [DurationUnit] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun durationUnit(durationUnit: JsonField) = apply { + this.durationUnit = durationUnit } fun additionalProperties(additionalProperties: Map) = @@ -33410,7 +30853,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackage && 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 && currency == other.currency && 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 */ @@ -33420,14 +30863,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredPackage{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredWithMinimumPrice + class TieredWithMinimum private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithMinimumConfig: JsonField, private val billableMetricId: JsonField, @@ -33454,7 +30897,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -33535,11 +30978,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -33681,16 +31128,6 @@ private constructor( */ @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]. * @@ -33838,13 +31275,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredWithMinimumPrice]. + * [TieredWithMinimum]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` @@ -33852,12 +31288,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredWithMinimumPrice]. */ + /** A builder for [TieredWithMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var tieredWithMinimumConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -33877,33 +31313,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionTieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice - ) = apply { - cadence = newSubscriptionTieredWithMinimumPrice.cadence - itemId = newSubscriptionTieredWithMinimumPrice.itemId - modelType = newSubscriptionTieredWithMinimumPrice.modelType - name = newSubscriptionTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newSubscriptionTieredWithMinimumPrice.billableMetricId - billedInAdvance = newSubscriptionTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredWithMinimumPrice.conversionRate - currency = newSubscriptionTieredWithMinimumPrice.currency - externalPriceId = newSubscriptionTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredWithMinimumPrice.metadata - referenceId = newSubscriptionTieredWithMinimumPrice.referenceId - additionalProperties = - newSubscriptionTieredWithMinimumPrice.additionalProperties - .toMutableMap() + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + currency = tieredWithMinimum.currency + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -33930,18 +31357,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -34276,7 +31704,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredWithMinimumPrice]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -34284,18 +31712,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredWithMinimumPrice = - NewSubscriptionTieredWithMinimumPrice( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), billableMetricId, @@ -34315,14 +31742,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithMinimumConfig().validate() billableMetricId() @@ -34357,7 +31788,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -34531,135 +31964,6 @@ private constructor( 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_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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 TieredWithMinimumConfig @JsonCreator private constructor( @@ -35612,7 +32916,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithMinimum && 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 && currency == other.currency && 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 */ @@ -35622,14 +32926,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionUnitWithPercentPrice + class UnitWithPercent private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithPercentConfig: JsonField, private val billableMetricId: JsonField, @@ -35656,7 +32960,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -35737,11 +33041,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -35883,16 +33191,6 @@ private constructor( */ @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]. * @@ -36039,14 +33337,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitWithPercentPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` @@ -36054,12 +33350,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitWithPercentPrice]. */ + /** A builder for [UnitWithPercent]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") private var name: JsonField? = null private var unitWithPercentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -36079,30 +33375,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionUnitWithPercentPrice: NewSubscriptionUnitWithPercentPrice - ) = apply { - cadence = newSubscriptionUnitWithPercentPrice.cadence - itemId = newSubscriptionUnitWithPercentPrice.itemId - modelType = newSubscriptionUnitWithPercentPrice.modelType - name = newSubscriptionUnitWithPercentPrice.name - unitWithPercentConfig = - newSubscriptionUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newSubscriptionUnitWithPercentPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithPercentPrice.conversionRate - currency = newSubscriptionUnitWithPercentPrice.currency - externalPriceId = newSubscriptionUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithPercentPrice.metadata - referenceId = newSubscriptionUnitWithPercentPrice.referenceId - additionalProperties = - newSubscriptionUnitWithPercentPrice.additionalProperties.toMutableMap() + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + currency = unitWithPercent.currency + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -36129,18 +33419,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -36475,7 +33766,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitWithPercentPrice]. + * Returns an immutable instance of [UnitWithPercent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -36483,18 +33774,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitWithPercentPrice = - NewSubscriptionUnitWithPercentPrice( + fun build(): UnitWithPercent = + UnitWithPercent( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithPercentConfig", unitWithPercentConfig), billableMetricId, @@ -36514,14 +33804,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitWithPercentPrice = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithPercentConfig().validate() billableMetricId() @@ -36556,7 +33850,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -36730,135 +34024,6 @@ private constructor( 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 UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * 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 { - UNIT_WITH_PERCENT, - /** - * 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) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - 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 UnitWithPercentConfig @JsonCreator private constructor( @@ -37810,7 +34975,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercent && 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 && currency == other.currency && 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 */ @@ -37820,14 +34985,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "UnitWithPercent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionPackageWithAllocationPrice + class PackageWithAllocation private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageWithAllocationConfig: JsonField, private val billableMetricId: JsonField, @@ -37854,7 +35019,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -37936,11 +35101,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -38082,16 +35251,6 @@ private constructor( */ @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]. * @@ -38239,13 +35398,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionPackageWithAllocationPrice]. + * [PackageWithAllocation]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` @@ -38253,12 +35411,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionPackageWithAllocationPrice]. */ + /** A builder for [PackageWithAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") private var name: JsonField? = null private var packageWithAllocationConfig: JsonField? = @@ -38280,35 +35438,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionPackageWithAllocationPrice: - NewSubscriptionPackageWithAllocationPrice - ) = apply { - cadence = newSubscriptionPackageWithAllocationPrice.cadence - itemId = newSubscriptionPackageWithAllocationPrice.itemId - modelType = newSubscriptionPackageWithAllocationPrice.modelType - name = newSubscriptionPackageWithAllocationPrice.name + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name packageWithAllocationConfig = - newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = - newSubscriptionPackageWithAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionPackageWithAllocationPrice.conversionRate - currency = newSubscriptionPackageWithAllocationPrice.currency - externalPriceId = newSubscriptionPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + currency = packageWithAllocation.currency + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionPackageWithAllocationPrice.metadata - referenceId = newSubscriptionPackageWithAllocationPrice.referenceId + packageWithAllocation.invoicingCycleConfiguration + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId additionalProperties = - newSubscriptionPackageWithAllocationPrice.additionalProperties - .toMutableMap() + packageWithAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -38335,18 +35485,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -38683,7 +35834,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionPackageWithAllocationPrice]. + * Returns an immutable instance of [PackageWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -38691,18 +35842,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionPackageWithAllocationPrice = - NewSubscriptionPackageWithAllocationPrice( + fun build(): PackageWithAllocation = + PackageWithAllocation( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "packageWithAllocationConfig", @@ -38725,14 +35875,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageWithAllocationConfig().validate() billableMetricId() @@ -38767,7 +35921,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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 (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -38941,135 +36097,6 @@ private constructor( 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 PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * 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 { - PACKAGE_WITH_ALLOCATION, - /** - * 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) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - 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 PackageWithAllocationConfig @JsonCreator private constructor( @@ -40023,7 +37050,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocation && 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 && currency == other.currency && 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 */ @@ -40033,14 +37060,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTierWithProrationPrice + class TieredWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -40067,7 +37094,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -40149,11 +37176,15 @@ private constructor( 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). + * 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). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -40295,16 +37326,6 @@ private constructor( */ @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]. * @@ -40452,13 +37473,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTierWithProrationPrice]. + * [TieredWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` @@ -40466,12 +37486,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTierWithProrationPrice]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null private var tieredWithProrationConfig: JsonField? = null @@ -40492,33 +37512,26 @@ private constructor( 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 - currency = newSubscriptionTierWithProrationPrice.currency - externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTierWithProrationPrice.invoiceGroupingKey + 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 + currency = tieredWithProration.currency + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionTierWithProrationPrice.metadata - referenceId = newSubscriptionTierWithProrationPrice.referenceId + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId additionalProperties = - newSubscriptionTierWithProrationPrice.additionalProperties - .toMutableMap() + tieredWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -40545,18 +37558,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -40892,7 +37906,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTierWithProrationPrice]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -40900,18 +37914,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, @@ -40931,14 +37944,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTierWithProrationPrice = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithProrationConfig().validate() billableMetricId() @@ -40973,7 +37990,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -41147,135 +38166,6 @@ private constructor( 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( @@ -42228,7 +39118,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 && currency == other.currency && 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 */ @@ -42238,14 +39128,14 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionUnitWithProrationPrice + class UnitWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -42272,7 +39162,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -42353,11 +39243,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -42499,16 +39393,6 @@ private constructor( */ @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]. * @@ -42656,13 +39540,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitWithProrationPrice]. + * [UnitWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` @@ -42670,12 +39553,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitWithProrationPrice]. */ + /** A builder for [UnitWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") private var name: JsonField? = null private var unitWithProrationConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -42695,33 +39578,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionUnitWithProrationPrice: NewSubscriptionUnitWithProrationPrice - ) = apply { - cadence = newSubscriptionUnitWithProrationPrice.cadence - itemId = newSubscriptionUnitWithProrationPrice.itemId - modelType = newSubscriptionUnitWithProrationPrice.modelType - name = newSubscriptionUnitWithProrationPrice.name - unitWithProrationConfig = - newSubscriptionUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newSubscriptionUnitWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithProrationPrice.conversionRate - currency = newSubscriptionUnitWithProrationPrice.currency - externalPriceId = newSubscriptionUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithProrationPrice.metadata - referenceId = newSubscriptionUnitWithProrationPrice.referenceId - additionalProperties = - newSubscriptionUnitWithProrationPrice.additionalProperties - .toMutableMap() + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + currency = unitWithProration.currency + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -42748,18 +39622,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -43094,7 +39969,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitWithProrationPrice]. + * Returns an immutable instance of [UnitWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -43102,18 +39977,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitWithProrationPrice = - NewSubscriptionUnitWithProrationPrice( + fun build(): UnitWithProration = + UnitWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithProrationConfig", unitWithProrationConfig), billableMetricId, @@ -43133,14 +40007,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitWithProrationPrice = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithProrationConfig().validate() billableMetricId() @@ -43175,7 +40053,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -43349,135 +40229,6 @@ private constructor( 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 UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_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 { - UNIT_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) { - UNIT_WITH_PRORATION -> Value.UNIT_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) { - UNIT_WITH_PRORATION -> Known.UNIT_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 UnitWithProrationConfig @JsonCreator private constructor( @@ -44430,7 +41181,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProration && 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 && currency == other.currency && 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 */ @@ -44440,15 +41191,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "UnitWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedAllocationPrice + class GroupedAllocation private constructor( private val cadence: JsonField, private val groupedAllocationConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -44477,7 +41228,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -44563,11 +41314,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -44712,16 +41467,6 @@ private constructor( */ @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]. * @@ -44858,27 +41603,26 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedAllocationPrice]. + * [GroupedAllocation]. * * The following fields are required: * ```java * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedAllocationPrice]. */ + /** A builder for [GroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedAllocationConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -44897,33 +41641,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedAllocationPrice: NewSubscriptionGroupedAllocationPrice - ) = apply { - cadence = newSubscriptionGroupedAllocationPrice.cadence - groupedAllocationConfig = - newSubscriptionGroupedAllocationPrice.groupedAllocationConfig - itemId = newSubscriptionGroupedAllocationPrice.itemId - modelType = newSubscriptionGroupedAllocationPrice.modelType - name = newSubscriptionGroupedAllocationPrice.name - billableMetricId = newSubscriptionGroupedAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedAllocationPrice.conversionRate - currency = newSubscriptionGroupedAllocationPrice.currency - externalPriceId = newSubscriptionGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedAllocationPrice.metadata - referenceId = newSubscriptionGroupedAllocationPrice.referenceId - additionalProperties = - newSubscriptionGroupedAllocationPrice.additionalProperties - .toMutableMap() + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + currency = groupedAllocation.currency + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -44964,18 +41699,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -45296,7 +42032,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionGroupedAllocationPrice]. + * Returns an immutable instance of [GroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -45305,18 +42041,17 @@ private constructor( * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedAllocationPrice = - NewSubscriptionGroupedAllocationPrice( + fun build(): GroupedAllocation = + GroupedAllocation( checkRequired("cadence", cadence), checkRequired("groupedAllocationConfig", groupedAllocationConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -45335,7 +42070,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedAllocationPrice = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -45343,7 +42078,11 @@ private constructor( cadence().validate() groupedAllocationConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -45378,7 +42117,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -45665,135 +42404,6 @@ private constructor( "GroupedAllocationConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * 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 { - GROUPED_ALLOCATION, - /** - * 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) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -46632,7 +43242,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocation && 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 && currency == other.currency && 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 */ @@ -46642,16 +43252,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedWithProratedMinimumPrice + class GroupedWithProratedMinimum private constructor( private val cadence: JsonField, private val groupedWithProratedMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -46681,7 +43291,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -46769,11 +43379,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -46918,16 +43532,6 @@ private constructor( */ @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]. * @@ -47064,21 +43668,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedWithProratedMinimumPrice]. + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedWithProratedMinimumPrice]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -47086,7 +43689,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -47105,41 +43709,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithProratedMinimumPrice: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithProratedMinimumPrice.cadence - groupedWithProratedMinimumConfig = - newSubscriptionGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newSubscriptionGroupedWithProratedMinimumPrice.itemId - modelType = newSubscriptionGroupedWithProratedMinimumPrice.modelType - name = newSubscriptionGroupedWithProratedMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithProratedMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithProratedMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + currency = groupedWithProratedMinimum.currency + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -47187,18 +43780,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -47519,8 +44113,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionGroupedWithProratedMinimumPrice]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -47529,21 +44122,20 @@ private constructor( * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedWithProratedMinimumPrice = - NewSubscriptionGroupedWithProratedMinimumPrice( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithProratedMinimumConfig", groupedWithProratedMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -47562,7 +44154,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -47570,7 +44162,11 @@ private constructor( cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -47605,7 +44201,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -47893,136 +44491,6 @@ private constructor( "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -48861,7 +45329,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimum && 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 && currency == other.currency && 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 */ @@ -48871,15 +45339,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkWithProrationPrice + class BulkWithProration private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -48908,7 +45376,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -48994,11 +45462,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -49143,16 +45615,6 @@ private constructor( */ @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]. * @@ -49289,27 +45751,26 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkWithProrationPrice]. + * [BulkWithProration]. * * The following fields are required: * ```java * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkWithProrationPrice]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -49328,33 +45789,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionBulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig - cadence = newSubscriptionBulkWithProrationPrice.cadence - itemId = newSubscriptionBulkWithProrationPrice.itemId - modelType = newSubscriptionBulkWithProrationPrice.modelType - name = newSubscriptionBulkWithProrationPrice.name - billableMetricId = newSubscriptionBulkWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkWithProrationPrice.conversionRate - currency = newSubscriptionBulkWithProrationPrice.currency - externalPriceId = newSubscriptionBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkWithProrationPrice.metadata - referenceId = newSubscriptionBulkWithProrationPrice.referenceId - additionalProperties = - newSubscriptionBulkWithProrationPrice.additionalProperties - .toMutableMap() + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + currency = bulkWithProration.currency + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = @@ -49395,18 +45847,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -49727,7 +46180,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkWithProrationPrice]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -49736,18 +46189,17 @@ private constructor( * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkWithProrationPrice = - NewSubscriptionBulkWithProrationPrice( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -49766,7 +46218,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkWithProrationPrice = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -49774,7 +46226,11 @@ private constructor( bulkWithProrationConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -49809,7 +46265,9 @@ private constructor( (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -50096,135 +46554,6 @@ private constructor( 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 BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_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 { - BULK_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) { - BULK_WITH_PRORATION -> Value.BULK_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) { - BULK_WITH_PRORATION -> Known.BULK_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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -51063,7 +47392,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkWithProration && 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 && currency == other.currency && 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 */ @@ -51073,14 +47402,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionScalableMatrixWithUnitPricingPrice + class ScalableMatrixWithUnitPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithUnitPricingConfig: JsonField, @@ -51108,7 +47437,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -51191,11 +47520,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -51339,16 +47672,6 @@ private constructor( */ @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]. * @@ -51497,13 +47820,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionScalableMatrixWithUnitPricingPrice]. + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` @@ -51511,12 +47833,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var scalableMatrixWithUnitPricingConfig: JsonField? = @@ -51539,40 +47862,29 @@ private constructor( @JvmSynthetic internal fun from( - newSubscriptionScalableMatrixWithUnitPricingPrice: - NewSubscriptionScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = apply { - cadence = newSubscriptionScalableMatrixWithUnitPricingPrice.cadence - itemId = newSubscriptionScalableMatrixWithUnitPricingPrice.itemId - modelType = newSubscriptionScalableMatrixWithUnitPricingPrice.modelType - name = newSubscriptionScalableMatrixWithUnitPricingPrice.name + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name scalableMatrixWithUnitPricingConfig = - newSubscriptionScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = - newSubscriptionScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = - newSubscriptionScalableMatrixWithUnitPricingPrice.billedInAdvance + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance billingCycleConfiguration = - newSubscriptionScalableMatrixWithUnitPricingPrice - .billingCycleConfiguration - conversionRate = - newSubscriptionScalableMatrixWithUnitPricingPrice.conversionRate - currency = newSubscriptionScalableMatrixWithUnitPricingPrice.currency - externalPriceId = - newSubscriptionScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionScalableMatrixWithUnitPricingPrice.invoiceGroupingKey + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + currency = scalableMatrixWithUnitPricing.currency + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionScalableMatrixWithUnitPricingPrice - .invoicingCycleConfiguration - metadata = newSubscriptionScalableMatrixWithUnitPricingPrice.metadata - referenceId = newSubscriptionScalableMatrixWithUnitPricingPrice.referenceId + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId additionalProperties = - newSubscriptionScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -51599,18 +47911,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -51955,8 +48268,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionScalableMatrixWithUnitPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -51964,18 +48276,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionScalableMatrixWithUnitPricingPrice = - NewSubscriptionScalableMatrixWithUnitPricingPrice( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithUnitPricingConfig", @@ -51998,14 +48309,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionScalableMatrixWithUnitPricingPrice = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -52040,7 +48355,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -52215,139 +48532,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_UNIT_PRICING = - of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - 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 ScalableMatrixWithUnitPricingConfig @JsonCreator private constructor( @@ -53302,7 +49486,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithUnitPricing && 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 && currency == other.currency && 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 */ @@ -53312,14 +49496,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionScalableMatrixWithTieredPricingPrice + class ScalableMatrixWithTieredPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithTieredPricingConfig: JsonField, @@ -53347,7 +49531,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -53430,11 +49614,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -53578,16 +49766,6 @@ private constructor( */ @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]. * @@ -53736,13 +49914,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionScalableMatrixWithTieredPricingPrice]. + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` @@ -53750,12 +49927,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionScalableMatrixWithTieredPricingPrice]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var scalableMatrixWithTieredPricingConfig: JsonField? = @@ -53778,41 +49956,29 @@ private constructor( @JvmSynthetic internal fun from( - newSubscriptionScalableMatrixWithTieredPricingPrice: - NewSubscriptionScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = apply { - cadence = newSubscriptionScalableMatrixWithTieredPricingPrice.cadence - itemId = newSubscriptionScalableMatrixWithTieredPricingPrice.itemId - modelType = newSubscriptionScalableMatrixWithTieredPricingPrice.modelType - name = newSubscriptionScalableMatrixWithTieredPricingPrice.name + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name scalableMatrixWithTieredPricingConfig = - newSubscriptionScalableMatrixWithTieredPricingPrice - .scalableMatrixWithTieredPricingConfig - billableMetricId = - newSubscriptionScalableMatrixWithTieredPricingPrice.billableMetricId - billedInAdvance = - newSubscriptionScalableMatrixWithTieredPricingPrice.billedInAdvance + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance billingCycleConfiguration = - newSubscriptionScalableMatrixWithTieredPricingPrice - .billingCycleConfiguration - conversionRate = - newSubscriptionScalableMatrixWithTieredPricingPrice.conversionRate - currency = newSubscriptionScalableMatrixWithTieredPricingPrice.currency - externalPriceId = - newSubscriptionScalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionScalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionScalableMatrixWithTieredPricingPrice.invoiceGroupingKey + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + currency = scalableMatrixWithTieredPricing.currency + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionScalableMatrixWithTieredPricingPrice - .invoicingCycleConfiguration - metadata = newSubscriptionScalableMatrixWithTieredPricingPrice.metadata - referenceId = - newSubscriptionScalableMatrixWithTieredPricingPrice.referenceId + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId additionalProperties = - newSubscriptionScalableMatrixWithTieredPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -53839,18 +50005,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -54195,8 +50362,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionScalableMatrixWithTieredPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -54204,18 +50370,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionScalableMatrixWithTieredPricingPrice = - NewSubscriptionScalableMatrixWithTieredPricingPrice( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithTieredPricingConfig", @@ -54238,14 +50403,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionScalableMatrixWithTieredPricingPrice = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -54280,7 +50449,10 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -54455,139 +50627,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - 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 ScalableMatrixWithTieredPricingConfig @JsonCreator private constructor( @@ -55545,7 +51584,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithTieredPricing && 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 && currency == other.currency && 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 */ @@ -55555,15 +51594,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionCumulativeGroupedBulkPrice + class CumulativeGroupedBulk private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -55593,7 +51632,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -55679,11 +51718,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -55828,16 +51871,6 @@ private constructor( */ @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]. * @@ -55974,21 +52007,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionCumulativeGroupedBulkPrice]. + * [CumulativeGroupedBulk]. * * The following fields are required: * ```java * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionCumulativeGroupedBulkPrice]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -55996,7 +52028,7 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -56015,35 +52047,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionCumulativeGroupedBulkPrice: - NewSubscriptionCumulativeGroupedBulkPrice - ) = apply { - cadence = newSubscriptionCumulativeGroupedBulkPrice.cadence + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence cumulativeGroupedBulkConfig = - newSubscriptionCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - itemId = newSubscriptionCumulativeGroupedBulkPrice.itemId - modelType = newSubscriptionCumulativeGroupedBulkPrice.modelType - name = newSubscriptionCumulativeGroupedBulkPrice.name - billableMetricId = - newSubscriptionCumulativeGroupedBulkPrice.billableMetricId - billedInAdvance = newSubscriptionCumulativeGroupedBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionCumulativeGroupedBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionCumulativeGroupedBulkPrice.conversionRate - currency = newSubscriptionCumulativeGroupedBulkPrice.currency - externalPriceId = newSubscriptionCumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionCumulativeGroupedBulkPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionCumulativeGroupedBulkPrice.invoiceGroupingKey + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + currency = cumulativeGroupedBulk.currency + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionCumulativeGroupedBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionCumulativeGroupedBulkPrice.metadata - referenceId = newSubscriptionCumulativeGroupedBulkPrice.referenceId + cumulativeGroupedBulk.invoicingCycleConfiguration + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId additionalProperties = - newSubscriptionCumulativeGroupedBulkPrice.additionalProperties - .toMutableMap() + cumulativeGroupedBulk.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -56086,18 +52110,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -56418,7 +52443,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionCumulativeGroupedBulkPrice]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -56427,21 +52452,20 @@ private constructor( * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionCumulativeGroupedBulkPrice = - NewSubscriptionCumulativeGroupedBulkPrice( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("cadence", cadence), checkRequired( "cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -56460,7 +52484,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionCumulativeGroupedBulkPrice = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -56468,7 +52492,11 @@ private constructor( cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -56503,7 +52531,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -56791,135 +52821,6 @@ private constructor( "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * 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 { - CUMULATIVE_GROUPED_BULK, - /** - * 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) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -57758,7 +53659,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CumulativeGroupedBulk && 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 && currency == other.currency && 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 */ @@ -57768,15 +53669,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMaxGroupTieredPackagePrice + class MaxGroupTieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, private val maxGroupTieredPackageConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -57806,7 +53707,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -57892,11 +53793,15 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_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). + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -58041,16 +53946,6 @@ private constructor( fun _maxGroupTieredPackageConfig(): JsonField = maxGroupTieredPackageConfig - /** - * 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]. * @@ -58187,21 +54082,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMaxGroupTieredPackagePrice]. + * [MaxGroupTieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMaxGroupTieredPackagePrice]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -58209,7 +54103,7 @@ private constructor( private var maxGroupTieredPackageConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -58228,35 +54122,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionMaxGroupTieredPackagePrice: - NewSubscriptionMaxGroupTieredPackagePrice - ) = apply { - cadence = newSubscriptionMaxGroupTieredPackagePrice.cadence - itemId = newSubscriptionMaxGroupTieredPackagePrice.itemId + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId maxGroupTieredPackageConfig = - newSubscriptionMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newSubscriptionMaxGroupTieredPackagePrice.modelType - name = newSubscriptionMaxGroupTieredPackagePrice.name - billableMetricId = - newSubscriptionMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionMaxGroupTieredPackagePrice.conversionRate - currency = newSubscriptionMaxGroupTieredPackagePrice.currency - externalPriceId = newSubscriptionMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionMaxGroupTieredPackagePrice.invoiceGroupingKey + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + currency = maxGroupTieredPackage.currency + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionMaxGroupTieredPackagePrice.metadata - referenceId = newSubscriptionMaxGroupTieredPackagePrice.referenceId + maxGroupTieredPackage.invoicingCycleConfiguration + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId additionalProperties = - newSubscriptionMaxGroupTieredPackagePrice.additionalProperties - .toMutableMap() + maxGroupTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -58299,18 +54185,19 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -58631,7 +54518,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMaxGroupTieredPackagePrice]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -58640,21 +54527,20 @@ private constructor( * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMaxGroupTieredPackagePrice = - NewSubscriptionMaxGroupTieredPackagePrice( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired( "maxGroupTieredPackageConfig", maxGroupTieredPackageConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -58673,7 +54559,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMaxGroupTieredPackagePrice = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -58681,7 +54567,11 @@ private constructor( cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -58716,7 +54606,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -59004,135 +54896,6 @@ private constructor( "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * 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 { - MAX_GROUP_TIERED_PACKAGE, - /** - * 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) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -59971,7 +55734,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MaxGroupTieredPackage && 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 && currency == other.currency && 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 */ @@ -59981,16 +55744,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedWithMeteredMinimumPrice + class GroupedWithMeteredMinimum private constructor( private val cadence: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -60020,7 +55783,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -60108,11 +55871,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -60257,16 +56024,6 @@ private constructor( */ @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]. * @@ -60403,21 +56160,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedWithMeteredMinimumPrice]. + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedWithMeteredMinimumPrice]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -60425,7 +56181,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -60444,41 +56201,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithMeteredMinimumPrice: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithMeteredMinimumPrice.cadence - groupedWithMeteredMinimumConfig = - newSubscriptionGroupedWithMeteredMinimumPrice - .groupedWithMeteredMinimumConfig - itemId = newSubscriptionGroupedWithMeteredMinimumPrice.itemId - modelType = newSubscriptionGroupedWithMeteredMinimumPrice.modelType - name = newSubscriptionGroupedWithMeteredMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithMeteredMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithMeteredMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithMeteredMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithMeteredMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithMeteredMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithMeteredMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithMeteredMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + currency = groupedWithMeteredMinimum.currency + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -60525,18 +56271,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -60857,8 +56604,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionGroupedWithMeteredMinimumPrice]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -60867,21 +56613,20 @@ private constructor( * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedWithMeteredMinimumPrice = - NewSubscriptionGroupedWithMeteredMinimumPrice( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithMeteredMinimumConfig", groupedWithMeteredMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -60900,7 +56645,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedWithMeteredMinimumPrice = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -60908,7 +56653,11 @@ private constructor( cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -60943,7 +56692,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -61231,136 +56982,6 @@ private constructor( "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -62199,7 +57820,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimum && 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 && currency == other.currency && 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 */ @@ -62209,15 +57830,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMatrixWithDisplayNamePrice + class MatrixWithDisplayName private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixWithDisplayNameConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -62247,7 +57868,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -62333,11 +57954,15 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -62482,16 +58107,6 @@ private constructor( fun _matrixWithDisplayNameConfig(): JsonField = matrixWithDisplayNameConfig - /** - * 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]. * @@ -62628,21 +58243,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMatrixWithDisplayNamePrice]. + * [MatrixWithDisplayName]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMatrixWithDisplayNamePrice]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -62650,7 +58264,7 @@ private constructor( private var matrixWithDisplayNameConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -62669,35 +58283,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionMatrixWithDisplayNamePrice: - NewSubscriptionMatrixWithDisplayNamePrice - ) = apply { - cadence = newSubscriptionMatrixWithDisplayNamePrice.cadence - itemId = newSubscriptionMatrixWithDisplayNamePrice.itemId + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId matrixWithDisplayNameConfig = - newSubscriptionMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newSubscriptionMatrixWithDisplayNamePrice.modelType - name = newSubscriptionMatrixWithDisplayNamePrice.name - billableMetricId = - newSubscriptionMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newSubscriptionMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixWithDisplayNamePrice.conversionRate - currency = newSubscriptionMatrixWithDisplayNamePrice.currency - externalPriceId = newSubscriptionMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionMatrixWithDisplayNamePrice.invoiceGroupingKey + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + currency = matrixWithDisplayName.currency + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixWithDisplayNamePrice.metadata - referenceId = newSubscriptionMatrixWithDisplayNamePrice.referenceId + matrixWithDisplayName.invoicingCycleConfiguration + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId additionalProperties = - newSubscriptionMatrixWithDisplayNamePrice.additionalProperties - .toMutableMap() + matrixWithDisplayName.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -62740,18 +58346,19 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -63072,7 +58679,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMatrixWithDisplayNamePrice]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -63081,21 +58688,20 @@ private constructor( * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMatrixWithDisplayNamePrice = - NewSubscriptionMatrixWithDisplayNamePrice( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired( "matrixWithDisplayNameConfig", matrixWithDisplayNameConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -63114,7 +58720,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMatrixWithDisplayNamePrice = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -63122,7 +58728,11 @@ private constructor( cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -63157,7 +58767,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -63445,135 +59057,6 @@ private constructor( "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * 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 { - MATRIX_WITH_DISPLAY_NAME, - /** - * 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) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -64412,7 +59895,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayName && 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 && currency == other.currency && 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 */ @@ -64422,15 +59905,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedTieredPackagePrice + class GroupedTieredPackage private constructor( private val cadence: JsonField, private val groupedTieredPackageConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -64460,7 +59943,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -64546,11 +60029,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -64695,16 +60182,6 @@ private constructor( */ @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]. * @@ -64841,28 +60318,27 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedTieredPackagePrice]. + * [GroupedTieredPackage]. * * The following fields are required: * ```java * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedTieredPackagePrice]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedTieredPackageConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -64881,34 +60357,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedTieredPackagePrice: - NewSubscriptionGroupedTieredPackagePrice - ) = apply { - cadence = newSubscriptionGroupedTieredPackagePrice.cadence - groupedTieredPackageConfig = - newSubscriptionGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newSubscriptionGroupedTieredPackagePrice.itemId - modelType = newSubscriptionGroupedTieredPackagePrice.modelType - name = newSubscriptionGroupedTieredPackagePrice.name - billableMetricId = newSubscriptionGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionGroupedTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedTieredPackagePrice.conversionRate - currency = newSubscriptionGroupedTieredPackagePrice.currency - externalPriceId = newSubscriptionGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedTieredPackagePrice.invoiceGroupingKey + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + currency = groupedTieredPackage.currency + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedTieredPackagePrice.metadata - referenceId = newSubscriptionGroupedTieredPackagePrice.referenceId + groupedTieredPackage.invoicingCycleConfiguration + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId additionalProperties = - newSubscriptionGroupedTieredPackagePrice.additionalProperties - .toMutableMap() + groupedTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -64951,18 +60419,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -65283,7 +60752,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionGroupedTieredPackagePrice]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -65292,18 +60761,17 @@ private constructor( * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedTieredPackagePrice = - NewSubscriptionGroupedTieredPackagePrice( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("cadence", cadence), checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -65322,7 +60790,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedTieredPackagePrice = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -65330,7 +60798,11 @@ private constructor( cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -65365,7 +60837,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -65652,135 +61126,6 @@ private constructor( "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * 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 { - GROUPED_TIERED_PACKAGE, - /** - * 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) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -66619,7 +61964,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPackage && 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 && currency == other.currency && 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 */ @@ -66629,7 +61974,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } } @@ -67524,32 +62869,26 @@ private constructor( /** * Alias for calling [adjustment] with - * `Adjustment.ofNewPercentageDiscount(newPercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = - adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewUsageDiscount(newUsageDiscount)`. - */ - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = - adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofNewAmountDiscount(newAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = - adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMinimum(newMinimum)`. */ - fun adjustment(newMinimum: Adjustment.NewMinimum) = - adjustment(Adjustment.ofNewMinimum(newMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** Alias for calling [adjustment] with `Adjustment.ofNewMaximum(newMaximum)`. */ - fun adjustment(newMaximum: Adjustment.NewMaximum) = - adjustment(Adjustment.ofNewMaximum(newMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The id of the adjustment on the plan to replace in the subscription. */ fun replacesAdjustmentId(replacesAdjustmentId: String) = @@ -67642,60 +62981,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val newPercentageDiscount: NewPercentageDiscount? = null, - private val newUsageDiscount: NewUsageDiscount? = null, - private val newAmountDiscount: NewAmountDiscount? = null, - private val newMinimum: NewMinimum? = null, - private val newMaximum: NewMaximum? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun newPercentageDiscount(): Optional = - Optional.ofNullable(newPercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun newUsageDiscount(): Optional = - Optional.ofNullable(newUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun newAmountDiscount(): Optional = - Optional.ofNullable(newAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun newMinimum(): Optional = Optional.ofNullable(newMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun newMaximum(): Optional = Optional.ofNullable(newMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isNewPercentageDiscount(): Boolean = newPercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isNewUsageDiscount(): Boolean = newUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isNewAmountDiscount(): Boolean = newAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isNewMinimum(): Boolean = newMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isNewMaximum(): Boolean = newMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asNewPercentageDiscount(): NewPercentageDiscount = - newPercentageDiscount.getOrThrow("newPercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asNewUsageDiscount(): NewUsageDiscount = - newUsageDiscount.getOrThrow("newUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asNewAmountDiscount(): NewAmountDiscount = - newAmountDiscount.getOrThrow("newAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asNewMinimum(): NewMinimum = newMinimum.getOrThrow("newMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asNewMaximum(): NewMaximum = newMaximum.getOrThrow("newMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newPercentageDiscount != null -> - visitor.visitNewPercentageDiscount(newPercentageDiscount) - newUsageDiscount != null -> visitor.visitNewUsageDiscount(newUsageDiscount) - newAmountDiscount != null -> visitor.visitNewAmountDiscount(newAmountDiscount) - newMinimum != null -> visitor.visitNewMinimum(newMinimum) - newMaximum != null -> visitor.visitNewMaximum(newMaximum) + 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) } @@ -67707,27 +63042,27 @@ private constructor( } accept( - object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount + object : Visitor { + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - newPercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) { - newUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) { - newAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitNewMinimum(newMinimum: NewMinimum) { - newMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitNewMaximum(newMaximum: NewMaximum) { - newMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -67752,19 +63087,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewPercentageDiscount( - newPercentageDiscount: NewPercentageDiscount - ) = newPercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - newUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - newAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitNewMinimum(newMinimum: NewMinimum) = newMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitNewMaximum(newMaximum: NewMaximum) = newMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -67775,19 +63110,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && newPercentageDiscount == other.newPercentageDiscount && newUsageDiscount == other.newUsageDiscount && newAmountDiscount == other.newAmountDiscount && newMinimum == other.newMinimum && newMaximum == other.newMaximum /* spotless:on */ + 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 hashCode(): Int = /* spotless:off */ Objects.hash(newPercentageDiscount, newUsageDiscount, newAmountDiscount, newMinimum, newMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(percentageDiscount, usageDiscount, amountDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - newPercentageDiscount != null -> - "Adjustment{newPercentageDiscount=$newPercentageDiscount}" - newUsageDiscount != null -> "Adjustment{newUsageDiscount=$newUsageDiscount}" - newAmountDiscount != null -> "Adjustment{newAmountDiscount=$newAmountDiscount}" - newMinimum != null -> "Adjustment{newMinimum=$newMinimum}" - newMaximum != null -> "Adjustment{newMaximum=$newMaximum}" + 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") } @@ -67795,22 +63130,20 @@ private constructor( companion object { @JvmStatic - fun ofNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount) = - Adjustment(newPercentageDiscount = newPercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) @JvmStatic - fun ofNewUsageDiscount(newUsageDiscount: NewUsageDiscount) = - Adjustment(newUsageDiscount = newUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofNewAmountDiscount(newAmountDiscount: NewAmountDiscount) = - Adjustment(newAmountDiscount = newAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) - @JvmStatic - fun ofNewMinimum(newMinimum: NewMinimum) = Adjustment(newMinimum = newMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofNewMaximum(newMaximum: NewMaximum) = Adjustment(newMaximum = newMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -67819,15 +63152,15 @@ private constructor( */ interface Visitor { - fun visitNewPercentageDiscount(newPercentageDiscount: NewPercentageDiscount): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitNewUsageDiscount(newUsageDiscount: NewUsageDiscount): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitNewAmountDiscount(newAmountDiscount: NewAmountDiscount): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitNewMinimum(newMinimum: NewMinimum): T + fun visitMinimum(minimum: Minimum): T - fun visitNewMaximum(newMaximum: NewMaximum): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -67853,28 +63186,28 @@ private constructor( when (adjustmentType) { "percentage_discount" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Adjustment(newPercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "usage_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newUsageDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newAmountDiscount = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMinimum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { - Adjustment(newMaximum = it, _json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) } ?: Adjustment(_json = json) } } @@ -67891,23 +63224,21 @@ private constructor( provider: SerializerProvider, ) { when { - value.newPercentageDiscount != null -> - generator.writeObject(value.newPercentageDiscount) - value.newUsageDiscount != null -> - generator.writeObject(value.newUsageDiscount) - value.newAmountDiscount != null -> - generator.writeObject(value.newAmountDiscount) - value.newMinimum != null -> generator.writeObject(value.newMinimum) - value.newMaximum != null -> generator.writeObject(value.newMaximum) + 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") } } } - class NewPercentageDiscount + class PercentageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val percentageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -67918,7 +63249,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -67937,11 +63268,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -67971,16 +63308,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -68027,11 +63354,10 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewPercentageDiscount]. + * [PercentageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` @@ -68039,37 +63365,39 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewPercentageDiscount]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var percentageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { - adjustmentType = newPercentageDiscount.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } - percentageDiscount = newPercentageDiscount.percentageDiscount - isInvoiceLevel = newPercentageDiscount.isInvoiceLevel + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.percentageDiscount = percentageDiscount.percentageDiscount + isInvoiceLevel = percentageDiscount.isInvoiceLevel additionalProperties = - newPercentageDiscount.additionalProperties.toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -68155,22 +63483,21 @@ private constructor( } /** - * Returns an immutable instance of [NewPercentageDiscount]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .percentageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewPercentageDiscount = - NewPercentageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): PercentageDiscount = + PercentageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -68182,12 +63509,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewPercentageDiscount = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() percentageDiscount() isInvoiceLevel() @@ -68210,147 +63543,19 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewPercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && percentageDiscount == other.percentageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -68360,12 +63565,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewPercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "PercentageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, percentageDiscount=$percentageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewUsageDiscount + class UsageDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val usageDiscount: JsonField, private val isInvoiceLevel: JsonField, @@ -68376,7 +63581,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -68395,11 +63600,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -68428,16 +63639,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -68483,11 +63684,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewUsageDiscount]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` @@ -68495,36 +63695,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewUsageDiscount]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var usageDiscount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newUsageDiscount: NewUsageDiscount) = apply { - adjustmentType = newUsageDiscount.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } - usageDiscount = newUsageDiscount.usageDiscount - isInvoiceLevel = newUsageDiscount.isInvoiceLevel - additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + this.usageDiscount = usageDiscount.usageDiscount + isInvoiceLevel = usageDiscount.isInvoiceLevel + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -68610,22 +63812,21 @@ private constructor( } /** - * Returns an immutable instance of [NewUsageDiscount]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .usageDiscount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewUsageDiscount = - NewUsageDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): UsageDiscount = + UsageDiscount( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -68637,12 +63838,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewUsageDiscount = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() usageDiscount() isInvoiceLevel() @@ -68665,147 +63872,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("usage_discount")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewUsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && usageDiscount == other.usageDiscount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -68815,12 +63892,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewUsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "UsageDiscount{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, usageDiscount=$usageDiscount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewAmountDiscount + class AmountDiscount private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -68831,7 +63908,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -68850,11 +63927,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * @throws OrbInvalidDataException if the JSON field has an unexpected type or is @@ -68883,16 +63966,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -68938,12 +64011,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewAmountDiscount]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` @@ -68951,36 +64022,38 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewAmountDiscount]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newAmountDiscount: NewAmountDiscount) = apply { - adjustmentType = newAmountDiscount.adjustmentType - amountDiscount = newAmountDiscount.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } - isInvoiceLevel = newAmountDiscount.isInvoiceLevel - additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -69066,22 +64139,21 @@ private constructor( } /** - * Returns an immutable instance of [NewAmountDiscount]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewAmountDiscount = - NewAmountDiscount( - checkRequired("adjustmentType", adjustmentType), + fun build(): AmountDiscount = + AmountDiscount( + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -69093,12 +64165,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewAmountDiscount = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -69121,147 +64199,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("amount_discount")) 1 else 0 } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewAmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -69271,12 +64219,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewAmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "AmountDiscount{adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMinimum + class Minimum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val itemId: JsonField, private val minimumAmount: JsonField, @@ -69288,7 +64236,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -69311,11 +64259,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -69353,16 +64307,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -69416,11 +64360,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMinimum]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -69429,10 +64372,10 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMinimum]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var itemId: JsonField? = null private var minimumAmount: JsonField? = null @@ -69440,26 +64383,28 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMinimum: NewMinimum) = apply { - adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } - itemId = newMinimum.itemId - minimumAmount = newMinimum.minimumAmount - isInvoiceLevel = newMinimum.isInvoiceLevel - additionalProperties = newMinimum.additionalProperties.toMutableMap() + internal fun from(minimum: Minimum) = apply { + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + isInvoiceLevel = minimum.isInvoiceLevel + additionalProperties = minimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -69557,13 +64502,12 @@ private constructor( } /** - * Returns an immutable instance of [NewMinimum]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .itemId() * .minimumAmount() @@ -69571,9 +64515,9 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMinimum = - NewMinimum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Minimum = + Minimum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -69586,12 +64530,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMinimum = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() itemId() minimumAmount() @@ -69615,148 +64565,18 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (if (minimumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMinimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && itemId == other.itemId && minimumAmount == other.minimumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -69766,12 +64586,12 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMinimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Minimum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, itemId=$itemId, minimumAmount=$minimumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } - class NewMaximum + class Maximum private constructor( - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val maximumAmount: JsonField, private val isInvoiceLevel: JsonField, @@ -69782,7 +64602,7 @@ private constructor( private constructor( @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -69801,11 +64621,17 @@ 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The set of price IDs to which this adjustment applies. @@ -69834,16 +64660,6 @@ private constructor( fun isInvoiceLevel(): Optional = isInvoiceLevel.getOptional("is_invoice_level") - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -69889,11 +64705,10 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [NewMaximum]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` @@ -69901,35 +64716,37 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewMaximum]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var maximumAmount: JsonField? = null private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newMaximum: NewMaximum) = apply { - adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } - maximumAmount = newMaximum.maximumAmount - isInvoiceLevel = newMaximum.isInvoiceLevel - additionalProperties = newMaximum.additionalProperties.toMutableMap() + internal fun from(maximum: Maximum) = apply { + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + maximumAmount = maximum.maximumAmount + isInvoiceLevel = maximum.isInvoiceLevel + additionalProperties = maximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -70015,22 +64832,21 @@ private constructor( } /** - * Returns an immutable instance of [NewMaximum]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .adjustmentType() * .appliesToPriceIds() * .maximumAmount() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewMaximum = - NewMaximum( - checkRequired("adjustmentType", adjustmentType), + fun build(): Maximum = + Maximum( + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -70042,12 +64858,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewMaximum = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() maximumAmount() isInvoiceLevel() @@ -70070,147 +64892,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is NewMaximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && maximumAmount == other.maximumAmount && isInvoiceLevel == other.isInvoiceLevel && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -70220,7 +64912,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewMaximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" + "Maximum{adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, maximumAmount=$maximumAmount, isInvoiceLevel=$isInvoiceLevel, additionalProperties=$additionalProperties}" } } @@ -70697,244 +65389,127 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } - /** - * Alias for calling [price] with `Price.ofNewSubscriptionUnit(newSubscriptionUnit)`. - */ - fun price(newSubscriptionUnit: Price.NewSubscriptionUnitPrice) = - price(Price.ofNewSubscriptionUnit(newSubscriptionUnit)) + /** Alias for calling [price] with `Price.ofUnit(unit)`. */ + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionPackage(newSubscriptionPackage)`. - */ - fun price(newSubscriptionPackage: Price.NewSubscriptionPackagePrice) = - price(Price.ofNewSubscriptionPackage(newSubscriptionPackage)) + /** Alias for calling [price] with `Price.ofPackage(package_)`. */ + fun price(package_: Price.Package) = price(Price.ofPackage(package_)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)`. - */ - fun price(newSubscriptionMatrix: Price.NewSubscriptionMatrixPrice) = - price(Price.ofNewSubscriptionMatrix(newSubscriptionMatrix)) + /** Alias for calling [price] with `Price.ofMatrix(matrix)`. */ + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTiered(newSubscriptionTiered)`. - */ - fun price(newSubscriptionTiered: Price.NewSubscriptionTieredPrice) = - price(Price.ofNewSubscriptionTiered(newSubscriptionTiered)) + /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)`. - */ - fun price(newSubscriptionTieredBps: Price.NewSubscriptionTieredBpsPrice) = - price(Price.ofNewSubscriptionTieredBps(newSubscriptionTieredBps)) + /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) - /** Alias for calling [price] with `Price.ofNewSubscriptionBps(newSubscriptionBps)`. */ - fun price(newSubscriptionBps: Price.NewSubscriptionBpsPrice) = - price(Price.ofNewSubscriptionBps(newSubscriptionBps)) + /** Alias for calling [price] with `Price.ofBps(bps)`. */ + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)`. - */ - fun price(newSubscriptionBulkBps: Price.NewSubscriptionBulkBpsPrice) = - price(Price.ofNewSubscriptionBulkBps(newSubscriptionBulkBps)) + /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) - /** - * Alias for calling [price] with `Price.ofNewSubscriptionBulk(newSubscriptionBulk)`. - */ - fun price(newSubscriptionBulk: Price.NewSubscriptionBulkPrice) = - price(Price.ofNewSubscriptionBulk(newSubscriptionBulk)) + /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount)`. + * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price( - newSubscriptionThresholdTotalAmount: Price.NewSubscriptionThresholdTotalAmountPrice - ) = - price( - Price.ofNewSubscriptionThresholdTotalAmount(newSubscriptionThresholdTotalAmount) - ) + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = + price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)`. - */ - fun price(newSubscriptionTieredPackage: Price.NewSubscriptionTieredPackagePrice) = - price(Price.ofNewSubscriptionTieredPackage(newSubscriptionTieredPackage)) + /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ + fun price(tieredPackage: Price.TieredPackage) = + price(Price.ofTieredPackage(tieredPackage)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)`. - */ - fun price( - newSubscriptionTieredWithMinimum: Price.NewSubscriptionTieredWithMinimumPrice - ) = price(Price.ofNewSubscriptionTieredWithMinimum(newSubscriptionTieredWithMinimum)) + /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ + fun price(tieredWithMinimum: Price.TieredWithMinimum) = + price(Price.ofTieredWithMinimum(tieredWithMinimum)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)`. - */ - fun price(newSubscriptionUnitWithPercent: Price.NewSubscriptionUnitWithPercentPrice) = - price(Price.ofNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent)) + /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ + fun price(unitWithPercent: Price.UnitWithPercent) = + price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionPackageWithAllocation(newSubscriptionPackageWithAllocation)`. + * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price( - newSubscriptionPackageWithAllocation: - Price.NewSubscriptionPackageWithAllocationPrice - ) = - price( - Price.ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - ) + fun price(packageWithAllocation: Price.PackageWithAllocation) = + price(Price.ofPackageWithAllocation(packageWithAllocation)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)`. + * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price( - newSubscriptionTierWithProration: Price.NewSubscriptionTierWithProrationPrice - ) = price(Price.ofNewSubscriptionTierWithProration(newSubscriptionTierWithProration)) + fun price(tieredWithProration: Price.TieredWithProration) = + price(Price.ofTieredWithProration(tieredWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)`. - */ - fun price( - newSubscriptionUnitWithProration: Price.NewSubscriptionUnitWithProrationPrice - ) = price(Price.ofNewSubscriptionUnitWithProration(newSubscriptionUnitWithProration)) + /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ + fun price(unitWithProration: Price.UnitWithProration) = + price(Price.ofUnitWithProration(unitWithProration)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)`. - */ - fun price( - newSubscriptionGroupedAllocation: Price.NewSubscriptionGroupedAllocationPrice - ) = price(Price.ofNewSubscriptionGroupedAllocation(newSubscriptionGroupedAllocation)) + /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ + fun price(groupedAllocation: Price.GroupedAllocation) = + price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedWithProratedMinimum(newSubscriptionGroupedWithProratedMinimum)`. + * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price( - newSubscriptionGroupedWithProratedMinimum: - Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - ) + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = + price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) - /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)`. - */ - fun price( - newSubscriptionBulkWithProration: Price.NewSubscriptionBulkWithProrationPrice - ) = price(Price.ofNewSubscriptionBulkWithProration(newSubscriptionBulkWithProration)) + /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ + fun price(bulkWithProration: Price.BulkWithProration) = + price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionScalableMatrixWithUnitPricing(newSubscriptionScalableMatrixWithUnitPricing)`. + * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price( - newSubscriptionScalableMatrixWithUnitPricing: - Price.NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = - price( - Price.ofNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing - ) - ) + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = + price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionScalableMatrixWithTieredPricing(newSubscriptionScalableMatrixWithTieredPricing)`. + * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price( - newSubscriptionScalableMatrixWithTieredPricing: - Price.NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = - price( - Price.ofNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing - ) - ) + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = + price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionCumulativeGroupedBulk(newSubscriptionCumulativeGroupedBulk)`. + * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price( - newSubscriptionCumulativeGroupedBulk: - Price.NewSubscriptionCumulativeGroupedBulkPrice - ) = - price( - Price.ofNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk - ) - ) + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = + price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionMaxGroupTieredPackage(newSubscriptionMaxGroupTieredPackage)`. + * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price( - newSubscriptionMaxGroupTieredPackage: - Price.NewSubscriptionMaxGroupTieredPackagePrice - ) = - price( - Price.ofNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage - ) - ) + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = + price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedWithMeteredMinimum(newSubscriptionGroupedWithMeteredMinimum)`. + * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price( - newSubscriptionGroupedWithMeteredMinimum: - Price.NewSubscriptionGroupedWithMeteredMinimumPrice - ) = - price( - Price.ofNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum - ) - ) + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = + price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with - * `Price.ofNewSubscriptionMatrixWithDisplayName(newSubscriptionMatrixWithDisplayName)`. + * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price( - newSubscriptionMatrixWithDisplayName: - Price.NewSubscriptionMatrixWithDisplayNamePrice - ) = - price( - Price.ofNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName - ) - ) + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = + price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** - * Alias for calling [price] with - * `Price.ofNewSubscriptionGroupedTieredPackage(newSubscriptionGroupedTieredPackage)`. + * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price( - newSubscriptionGroupedTieredPackage: Price.NewSubscriptionGroupedTieredPackagePrice - ) = - price( - Price.ofNewSubscriptionGroupedTieredPackage(newSubscriptionGroupedTieredPackage) - ) + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = + price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** The id of the price to add to the subscription. */ fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) @@ -71985,401 +66560,257 @@ private constructor( @JsonSerialize(using = Price.Serializer::class) class Price private constructor( - private val newSubscriptionUnit: NewSubscriptionUnitPrice? = null, - private val newSubscriptionPackage: NewSubscriptionPackagePrice? = null, - private val newSubscriptionMatrix: NewSubscriptionMatrixPrice? = null, - private val newSubscriptionTiered: NewSubscriptionTieredPrice? = null, - private val newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice? = null, - private val newSubscriptionBps: NewSubscriptionBpsPrice? = null, - private val newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice? = null, - private val newSubscriptionBulk: NewSubscriptionBulkPrice? = null, - private val newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice? = - null, - private val newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice? = null, - private val newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice? = - null, - private val newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice? = null, - private val newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice? = - null, - private val newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice? = - null, - private val newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice? = - null, - private val newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice? = - null, - private val newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice? = - null, - private val newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice? = - null, - private val newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice? = - null, - private val newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice? = - null, - private val newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice? = - null, - private val newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice? = - null, - private val newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice? = - null, - private val newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice? = - null, - private val newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice? = - null, + 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 thresholdTotalAmount: ThresholdTotalAmount? = null, + private val tieredPackage: TieredPackage? = null, + private val tieredWithMinimum: TieredWithMinimum? = null, + private val unitWithPercent: UnitWithPercent? = null, + private val packageWithAllocation: PackageWithAllocation? = null, + private val tieredWithProration: TieredWithProration? = null, + private val unitWithProration: UnitWithProration? = null, + private val groupedAllocation: GroupedAllocation? = null, + private val groupedWithProratedMinimum: GroupedWithProratedMinimum? = null, + private val bulkWithProration: BulkWithProration? = null, + private val scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing? = null, + private val scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing? = null, + private val cumulativeGroupedBulk: CumulativeGroupedBulk? = null, + private val maxGroupTieredPackage: MaxGroupTieredPackage? = null, + private val groupedWithMeteredMinimum: GroupedWithMeteredMinimum? = null, + private val matrixWithDisplayName: MatrixWithDisplayName? = null, + private val groupedTieredPackage: GroupedTieredPackage? = null, private val _json: JsonValue? = null, ) { - fun newSubscriptionUnit(): Optional = - Optional.ofNullable(newSubscriptionUnit) + fun unit(): Optional = Optional.ofNullable(unit) - fun newSubscriptionPackage(): Optional = - Optional.ofNullable(newSubscriptionPackage) + fun package_(): Optional = Optional.ofNullable(package_) - fun newSubscriptionMatrix(): Optional = - Optional.ofNullable(newSubscriptionMatrix) + fun matrix(): Optional = Optional.ofNullable(matrix) - fun newSubscriptionTiered(): Optional = - Optional.ofNullable(newSubscriptionTiered) + fun tiered(): Optional = Optional.ofNullable(tiered) - fun newSubscriptionTieredBps(): Optional = - Optional.ofNullable(newSubscriptionTieredBps) + fun tieredBps(): Optional = Optional.ofNullable(tieredBps) - fun newSubscriptionBps(): Optional = - Optional.ofNullable(newSubscriptionBps) + fun bps(): Optional = Optional.ofNullable(bps) - fun newSubscriptionBulkBps(): Optional = - Optional.ofNullable(newSubscriptionBulkBps) + fun bulkBps(): Optional = Optional.ofNullable(bulkBps) - fun newSubscriptionBulk(): Optional = - Optional.ofNullable(newSubscriptionBulk) + fun bulk(): Optional = Optional.ofNullable(bulk) - fun newSubscriptionThresholdTotalAmount(): - Optional = - Optional.ofNullable(newSubscriptionThresholdTotalAmount) + fun thresholdTotalAmount(): Optional = + Optional.ofNullable(thresholdTotalAmount) - fun newSubscriptionTieredPackage(): Optional = - Optional.ofNullable(newSubscriptionTieredPackage) + fun tieredPackage(): Optional = Optional.ofNullable(tieredPackage) - fun newSubscriptionTieredWithMinimum(): - Optional = - Optional.ofNullable(newSubscriptionTieredWithMinimum) + fun tieredWithMinimum(): Optional = + Optional.ofNullable(tieredWithMinimum) - fun newSubscriptionUnitWithPercent(): Optional = - Optional.ofNullable(newSubscriptionUnitWithPercent) + fun unitWithPercent(): Optional = Optional.ofNullable(unitWithPercent) - fun newSubscriptionPackageWithAllocation(): - Optional = - Optional.ofNullable(newSubscriptionPackageWithAllocation) + fun packageWithAllocation(): Optional = + Optional.ofNullable(packageWithAllocation) - fun newSubscriptionTierWithProration(): - Optional = - Optional.ofNullable(newSubscriptionTierWithProration) + fun tieredWithProration(): Optional = + Optional.ofNullable(tieredWithProration) - fun newSubscriptionUnitWithProration(): - Optional = - Optional.ofNullable(newSubscriptionUnitWithProration) + fun unitWithProration(): Optional = + Optional.ofNullable(unitWithProration) - fun newSubscriptionGroupedAllocation(): - Optional = - Optional.ofNullable(newSubscriptionGroupedAllocation) + fun groupedAllocation(): Optional = + Optional.ofNullable(groupedAllocation) - fun newSubscriptionGroupedWithProratedMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithProratedMinimum) + fun groupedWithProratedMinimum(): Optional = + Optional.ofNullable(groupedWithProratedMinimum) - fun newSubscriptionBulkWithProration(): - Optional = - Optional.ofNullable(newSubscriptionBulkWithProration) + fun bulkWithProration(): Optional = + Optional.ofNullable(bulkWithProration) - fun newSubscriptionScalableMatrixWithUnitPricing(): - Optional = - Optional.ofNullable(newSubscriptionScalableMatrixWithUnitPricing) + fun scalableMatrixWithUnitPricing(): Optional = + Optional.ofNullable(scalableMatrixWithUnitPricing) - fun newSubscriptionScalableMatrixWithTieredPricing(): - Optional = - Optional.ofNullable(newSubscriptionScalableMatrixWithTieredPricing) + fun scalableMatrixWithTieredPricing(): Optional = + Optional.ofNullable(scalableMatrixWithTieredPricing) - fun newSubscriptionCumulativeGroupedBulk(): - Optional = - Optional.ofNullable(newSubscriptionCumulativeGroupedBulk) + fun cumulativeGroupedBulk(): Optional = + Optional.ofNullable(cumulativeGroupedBulk) - fun newSubscriptionMaxGroupTieredPackage(): - Optional = - Optional.ofNullable(newSubscriptionMaxGroupTieredPackage) + fun maxGroupTieredPackage(): Optional = + Optional.ofNullable(maxGroupTieredPackage) - fun newSubscriptionGroupedWithMeteredMinimum(): - Optional = - Optional.ofNullable(newSubscriptionGroupedWithMeteredMinimum) + fun groupedWithMeteredMinimum(): Optional = + Optional.ofNullable(groupedWithMeteredMinimum) - fun newSubscriptionMatrixWithDisplayName(): - Optional = - Optional.ofNullable(newSubscriptionMatrixWithDisplayName) + fun matrixWithDisplayName(): Optional = + Optional.ofNullable(matrixWithDisplayName) - fun newSubscriptionGroupedTieredPackage(): - Optional = - Optional.ofNullable(newSubscriptionGroupedTieredPackage) + fun groupedTieredPackage(): Optional = + Optional.ofNullable(groupedTieredPackage) - fun isNewSubscriptionUnit(): Boolean = newSubscriptionUnit != null + fun isUnit(): Boolean = unit != null - fun isNewSubscriptionPackage(): Boolean = newSubscriptionPackage != null + fun isPackage(): Boolean = package_ != null - fun isNewSubscriptionMatrix(): Boolean = newSubscriptionMatrix != null + fun isMatrix(): Boolean = matrix != null - fun isNewSubscriptionTiered(): Boolean = newSubscriptionTiered != null + fun isTiered(): Boolean = tiered != null - fun isNewSubscriptionTieredBps(): Boolean = newSubscriptionTieredBps != null + fun isTieredBps(): Boolean = tieredBps != null - fun isNewSubscriptionBps(): Boolean = newSubscriptionBps != null + fun isBps(): Boolean = bps != null - fun isNewSubscriptionBulkBps(): Boolean = newSubscriptionBulkBps != null + fun isBulkBps(): Boolean = bulkBps != null - fun isNewSubscriptionBulk(): Boolean = newSubscriptionBulk != null + fun isBulk(): Boolean = bulk != null - fun isNewSubscriptionThresholdTotalAmount(): Boolean = - newSubscriptionThresholdTotalAmount != null + fun isThresholdTotalAmount(): Boolean = thresholdTotalAmount != null - fun isNewSubscriptionTieredPackage(): Boolean = newSubscriptionTieredPackage != null + fun isTieredPackage(): Boolean = tieredPackage != null - fun isNewSubscriptionTieredWithMinimum(): Boolean = - newSubscriptionTieredWithMinimum != null + fun isTieredWithMinimum(): Boolean = tieredWithMinimum != null - fun isNewSubscriptionUnitWithPercent(): Boolean = newSubscriptionUnitWithPercent != null + fun isUnitWithPercent(): Boolean = unitWithPercent != null - fun isNewSubscriptionPackageWithAllocation(): Boolean = - newSubscriptionPackageWithAllocation != null + fun isPackageWithAllocation(): Boolean = packageWithAllocation != null - fun isNewSubscriptionTierWithProration(): Boolean = - newSubscriptionTierWithProration != null + fun isTieredWithProration(): Boolean = tieredWithProration != null - fun isNewSubscriptionUnitWithProration(): Boolean = - newSubscriptionUnitWithProration != null + fun isUnitWithProration(): Boolean = unitWithProration != null - fun isNewSubscriptionGroupedAllocation(): Boolean = - newSubscriptionGroupedAllocation != null + fun isGroupedAllocation(): Boolean = groupedAllocation != null - fun isNewSubscriptionGroupedWithProratedMinimum(): Boolean = - newSubscriptionGroupedWithProratedMinimum != null + fun isGroupedWithProratedMinimum(): Boolean = groupedWithProratedMinimum != null - fun isNewSubscriptionBulkWithProration(): Boolean = - newSubscriptionBulkWithProration != null + fun isBulkWithProration(): Boolean = bulkWithProration != null - fun isNewSubscriptionScalableMatrixWithUnitPricing(): Boolean = - newSubscriptionScalableMatrixWithUnitPricing != null + fun isScalableMatrixWithUnitPricing(): Boolean = scalableMatrixWithUnitPricing != null - fun isNewSubscriptionScalableMatrixWithTieredPricing(): Boolean = - newSubscriptionScalableMatrixWithTieredPricing != null + fun isScalableMatrixWithTieredPricing(): Boolean = + scalableMatrixWithTieredPricing != null - fun isNewSubscriptionCumulativeGroupedBulk(): Boolean = - newSubscriptionCumulativeGroupedBulk != null + fun isCumulativeGroupedBulk(): Boolean = cumulativeGroupedBulk != null - fun isNewSubscriptionMaxGroupTieredPackage(): Boolean = - newSubscriptionMaxGroupTieredPackage != null + fun isMaxGroupTieredPackage(): Boolean = maxGroupTieredPackage != null - fun isNewSubscriptionGroupedWithMeteredMinimum(): Boolean = - newSubscriptionGroupedWithMeteredMinimum != null + fun isGroupedWithMeteredMinimum(): Boolean = groupedWithMeteredMinimum != null - fun isNewSubscriptionMatrixWithDisplayName(): Boolean = - newSubscriptionMatrixWithDisplayName != null + fun isMatrixWithDisplayName(): Boolean = matrixWithDisplayName != null - fun isNewSubscriptionGroupedTieredPackage(): Boolean = - newSubscriptionGroupedTieredPackage != null + fun isGroupedTieredPackage(): Boolean = groupedTieredPackage != null - fun asNewSubscriptionUnit(): NewSubscriptionUnitPrice = - newSubscriptionUnit.getOrThrow("newSubscriptionUnit") + fun asUnit(): Unit = unit.getOrThrow("unit") - fun asNewSubscriptionPackage(): NewSubscriptionPackagePrice = - newSubscriptionPackage.getOrThrow("newSubscriptionPackage") + fun asPackage(): Package = package_.getOrThrow("package_") - fun asNewSubscriptionMatrix(): NewSubscriptionMatrixPrice = - newSubscriptionMatrix.getOrThrow("newSubscriptionMatrix") + fun asMatrix(): Matrix = matrix.getOrThrow("matrix") - fun asNewSubscriptionTiered(): NewSubscriptionTieredPrice = - newSubscriptionTiered.getOrThrow("newSubscriptionTiered") + fun asTiered(): Tiered = tiered.getOrThrow("tiered") - fun asNewSubscriptionTieredBps(): NewSubscriptionTieredBpsPrice = - newSubscriptionTieredBps.getOrThrow("newSubscriptionTieredBps") + fun asTieredBps(): TieredBps = tieredBps.getOrThrow("tieredBps") - fun asNewSubscriptionBps(): NewSubscriptionBpsPrice = - newSubscriptionBps.getOrThrow("newSubscriptionBps") + fun asBps(): Bps = bps.getOrThrow("bps") - fun asNewSubscriptionBulkBps(): NewSubscriptionBulkBpsPrice = - newSubscriptionBulkBps.getOrThrow("newSubscriptionBulkBps") + fun asBulkBps(): BulkBps = bulkBps.getOrThrow("bulkBps") - fun asNewSubscriptionBulk(): NewSubscriptionBulkPrice = - newSubscriptionBulk.getOrThrow("newSubscriptionBulk") + fun asBulk(): Bulk = bulk.getOrThrow("bulk") - fun asNewSubscriptionThresholdTotalAmount(): NewSubscriptionThresholdTotalAmountPrice = - newSubscriptionThresholdTotalAmount.getOrThrow( - "newSubscriptionThresholdTotalAmount" - ) + fun asThresholdTotalAmount(): ThresholdTotalAmount = + thresholdTotalAmount.getOrThrow("thresholdTotalAmount") - fun asNewSubscriptionTieredPackage(): NewSubscriptionTieredPackagePrice = - newSubscriptionTieredPackage.getOrThrow("newSubscriptionTieredPackage") + fun asTieredPackage(): TieredPackage = tieredPackage.getOrThrow("tieredPackage") - fun asNewSubscriptionTieredWithMinimum(): NewSubscriptionTieredWithMinimumPrice = - newSubscriptionTieredWithMinimum.getOrThrow("newSubscriptionTieredWithMinimum") + fun asTieredWithMinimum(): TieredWithMinimum = + tieredWithMinimum.getOrThrow("tieredWithMinimum") - fun asNewSubscriptionUnitWithPercent(): NewSubscriptionUnitWithPercentPrice = - newSubscriptionUnitWithPercent.getOrThrow("newSubscriptionUnitWithPercent") + fun asUnitWithPercent(): UnitWithPercent = unitWithPercent.getOrThrow("unitWithPercent") - fun asNewSubscriptionPackageWithAllocation(): - NewSubscriptionPackageWithAllocationPrice = - newSubscriptionPackageWithAllocation.getOrThrow( - "newSubscriptionPackageWithAllocation" - ) + fun asPackageWithAllocation(): PackageWithAllocation = + packageWithAllocation.getOrThrow("packageWithAllocation") - fun asNewSubscriptionTierWithProration(): NewSubscriptionTierWithProrationPrice = - newSubscriptionTierWithProration.getOrThrow("newSubscriptionTierWithProration") + fun asTieredWithProration(): TieredWithProration = + tieredWithProration.getOrThrow("tieredWithProration") - fun asNewSubscriptionUnitWithProration(): NewSubscriptionUnitWithProrationPrice = - newSubscriptionUnitWithProration.getOrThrow("newSubscriptionUnitWithProration") + fun asUnitWithProration(): UnitWithProration = + unitWithProration.getOrThrow("unitWithProration") - fun asNewSubscriptionGroupedAllocation(): NewSubscriptionGroupedAllocationPrice = - newSubscriptionGroupedAllocation.getOrThrow("newSubscriptionGroupedAllocation") + fun asGroupedAllocation(): GroupedAllocation = + groupedAllocation.getOrThrow("groupedAllocation") - fun asNewSubscriptionGroupedWithProratedMinimum(): - NewSubscriptionGroupedWithProratedMinimumPrice = - newSubscriptionGroupedWithProratedMinimum.getOrThrow( - "newSubscriptionGroupedWithProratedMinimum" - ) + fun asGroupedWithProratedMinimum(): GroupedWithProratedMinimum = + groupedWithProratedMinimum.getOrThrow("groupedWithProratedMinimum") - fun asNewSubscriptionBulkWithProration(): NewSubscriptionBulkWithProrationPrice = - newSubscriptionBulkWithProration.getOrThrow("newSubscriptionBulkWithProration") + fun asBulkWithProration(): BulkWithProration = + bulkWithProration.getOrThrow("bulkWithProration") - fun asNewSubscriptionScalableMatrixWithUnitPricing(): - NewSubscriptionScalableMatrixWithUnitPricingPrice = - newSubscriptionScalableMatrixWithUnitPricing.getOrThrow( - "newSubscriptionScalableMatrixWithUnitPricing" - ) + fun asScalableMatrixWithUnitPricing(): ScalableMatrixWithUnitPricing = + scalableMatrixWithUnitPricing.getOrThrow("scalableMatrixWithUnitPricing") - fun asNewSubscriptionScalableMatrixWithTieredPricing(): - NewSubscriptionScalableMatrixWithTieredPricingPrice = - newSubscriptionScalableMatrixWithTieredPricing.getOrThrow( - "newSubscriptionScalableMatrixWithTieredPricing" - ) + fun asScalableMatrixWithTieredPricing(): ScalableMatrixWithTieredPricing = + scalableMatrixWithTieredPricing.getOrThrow("scalableMatrixWithTieredPricing") - fun asNewSubscriptionCumulativeGroupedBulk(): - NewSubscriptionCumulativeGroupedBulkPrice = - newSubscriptionCumulativeGroupedBulk.getOrThrow( - "newSubscriptionCumulativeGroupedBulk" - ) + fun asCumulativeGroupedBulk(): CumulativeGroupedBulk = + cumulativeGroupedBulk.getOrThrow("cumulativeGroupedBulk") - fun asNewSubscriptionMaxGroupTieredPackage(): - NewSubscriptionMaxGroupTieredPackagePrice = - newSubscriptionMaxGroupTieredPackage.getOrThrow( - "newSubscriptionMaxGroupTieredPackage" - ) + fun asMaxGroupTieredPackage(): MaxGroupTieredPackage = + maxGroupTieredPackage.getOrThrow("maxGroupTieredPackage") - fun asNewSubscriptionGroupedWithMeteredMinimum(): - NewSubscriptionGroupedWithMeteredMinimumPrice = - newSubscriptionGroupedWithMeteredMinimum.getOrThrow( - "newSubscriptionGroupedWithMeteredMinimum" - ) + fun asGroupedWithMeteredMinimum(): GroupedWithMeteredMinimum = + groupedWithMeteredMinimum.getOrThrow("groupedWithMeteredMinimum") - fun asNewSubscriptionMatrixWithDisplayName(): - NewSubscriptionMatrixWithDisplayNamePrice = - newSubscriptionMatrixWithDisplayName.getOrThrow( - "newSubscriptionMatrixWithDisplayName" - ) + fun asMatrixWithDisplayName(): MatrixWithDisplayName = + matrixWithDisplayName.getOrThrow("matrixWithDisplayName") - fun asNewSubscriptionGroupedTieredPackage(): NewSubscriptionGroupedTieredPackagePrice = - newSubscriptionGroupedTieredPackage.getOrThrow( - "newSubscriptionGroupedTieredPackage" - ) + fun asGroupedTieredPackage(): GroupedTieredPackage = + groupedTieredPackage.getOrThrow("groupedTieredPackage") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - newSubscriptionUnit != null -> - visitor.visitNewSubscriptionUnit(newSubscriptionUnit) - newSubscriptionPackage != null -> - visitor.visitNewSubscriptionPackage(newSubscriptionPackage) - newSubscriptionMatrix != null -> - visitor.visitNewSubscriptionMatrix(newSubscriptionMatrix) - newSubscriptionTiered != null -> - visitor.visitNewSubscriptionTiered(newSubscriptionTiered) - newSubscriptionTieredBps != null -> - visitor.visitNewSubscriptionTieredBps(newSubscriptionTieredBps) - newSubscriptionBps != null -> - visitor.visitNewSubscriptionBps(newSubscriptionBps) - newSubscriptionBulkBps != null -> - visitor.visitNewSubscriptionBulkBps(newSubscriptionBulkBps) - newSubscriptionBulk != null -> - visitor.visitNewSubscriptionBulk(newSubscriptionBulk) - newSubscriptionThresholdTotalAmount != null -> - visitor.visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount - ) - newSubscriptionTieredPackage != null -> - visitor.visitNewSubscriptionTieredPackage(newSubscriptionTieredPackage) - newSubscriptionTieredWithMinimum != null -> - visitor.visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum - ) - newSubscriptionUnitWithPercent != null -> - visitor.visitNewSubscriptionUnitWithPercent(newSubscriptionUnitWithPercent) - newSubscriptionPackageWithAllocation != null -> - visitor.visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation - ) - newSubscriptionTierWithProration != null -> - visitor.visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration - ) - newSubscriptionUnitWithProration != null -> - visitor.visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration - ) - newSubscriptionGroupedAllocation != null -> - visitor.visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation - ) - newSubscriptionGroupedWithProratedMinimum != null -> - visitor.visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum - ) - newSubscriptionBulkWithProration != null -> - visitor.visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration - ) - newSubscriptionScalableMatrixWithUnitPricing != null -> - visitor.visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing - ) - newSubscriptionScalableMatrixWithTieredPricing != null -> - visitor.visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing - ) - newSubscriptionCumulativeGroupedBulk != null -> - visitor.visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk - ) - newSubscriptionMaxGroupTieredPackage != null -> - visitor.visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage - ) - newSubscriptionGroupedWithMeteredMinimum != null -> - visitor.visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum - ) - newSubscriptionMatrixWithDisplayName != null -> - visitor.visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName - ) - newSubscriptionGroupedTieredPackage != null -> - visitor.visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage + unit != null -> visitor.visitUnit(unit) + package_ != null -> visitor.visitPackage(package_) + matrix != null -> visitor.visitMatrix(matrix) + tiered != null -> visitor.visitTiered(tiered) + tieredBps != null -> visitor.visitTieredBps(tieredBps) + bps != null -> visitor.visitBps(bps) + bulkBps != null -> visitor.visitBulkBps(bulkBps) + bulk != null -> visitor.visitBulk(bulk) + thresholdTotalAmount != null -> + visitor.visitThresholdTotalAmount(thresholdTotalAmount) + tieredPackage != null -> visitor.visitTieredPackage(tieredPackage) + tieredWithMinimum != null -> visitor.visitTieredWithMinimum(tieredWithMinimum) + unitWithPercent != null -> visitor.visitUnitWithPercent(unitWithPercent) + packageWithAllocation != null -> + visitor.visitPackageWithAllocation(packageWithAllocation) + tieredWithProration != null -> + visitor.visitTieredWithProration(tieredWithProration) + unitWithProration != null -> visitor.visitUnitWithProration(unitWithProration) + groupedAllocation != null -> visitor.visitGroupedAllocation(groupedAllocation) + groupedWithProratedMinimum != null -> + visitor.visitGroupedWithProratedMinimum(groupedWithProratedMinimum) + bulkWithProration != null -> visitor.visitBulkWithProration(bulkWithProration) + scalableMatrixWithUnitPricing != null -> + visitor.visitScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) + scalableMatrixWithTieredPricing != null -> + visitor.visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing ) + cumulativeGroupedBulk != null -> + visitor.visitCumulativeGroupedBulk(cumulativeGroupedBulk) + maxGroupTieredPackage != null -> + visitor.visitMaxGroupTieredPackage(maxGroupTieredPackage) + groupedWithMeteredMinimum != null -> + visitor.visitGroupedWithMeteredMinimum(groupedWithMeteredMinimum) + matrixWithDisplayName != null -> + visitor.visitMatrixWithDisplayName(matrixWithDisplayName) + groupedTieredPackage != null -> + visitor.visitGroupedTieredPackage(groupedTieredPackage) else -> visitor.unknown(_json) } @@ -72391,165 +66822,127 @@ private constructor( } accept( - object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) { - newSubscriptionUnit.validate() + object : Visitor { + override fun visitUnit(unit: Unit) { + unit.validate() } - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) { - newSubscriptionPackage.validate() + override fun visitPackage(package_: Package) { + package_.validate() } - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) { - newSubscriptionMatrix.validate() + override fun visitMatrix(matrix: Matrix) { + matrix.validate() } - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) { - newSubscriptionTiered.validate() + override fun visitTiered(tiered: Tiered) { + tiered.validate() } - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) { - newSubscriptionTieredBps.validate() + override fun visitTieredBps(tieredBps: TieredBps) { + tieredBps.validate() } - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) { - newSubscriptionBps.validate() + override fun visitBps(bps: Bps) { + bps.validate() } - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) { - newSubscriptionBulkBps.validate() + override fun visitBulkBps(bulkBps: BulkBps) { + bulkBps.validate() } - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) { - newSubscriptionBulk.validate() + override fun visitBulk(bulk: Bulk) { + bulk.validate() } - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount ) { - newSubscriptionThresholdTotalAmount.validate() + thresholdTotalAmount.validate() } - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) { - newSubscriptionTieredPackage.validate() + override fun visitTieredPackage(tieredPackage: TieredPackage) { + tieredPackage.validate() } - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) { - newSubscriptionTieredWithMinimum.validate() + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) { + tieredWithMinimum.validate() } - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) { - newSubscriptionUnitWithPercent.validate() + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) { + unitWithPercent.validate() } - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation ) { - newSubscriptionPackageWithAllocation.validate() + packageWithAllocation.validate() } - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration ) { - newSubscriptionTierWithProration.validate() + tieredWithProration.validate() } - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) { - newSubscriptionUnitWithProration.validate() + override fun visitUnitWithProration(unitWithProration: UnitWithProration) { + unitWithProration.validate() } - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) { - newSubscriptionGroupedAllocation.validate() + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) { + groupedAllocation.validate() } - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ) { - newSubscriptionGroupedWithProratedMinimum.validate() + groupedWithProratedMinimum.validate() } - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) { - newSubscriptionBulkWithProration.validate() + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) { + bulkWithProration.validate() } - override fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) { - newSubscriptionScalableMatrixWithUnitPricing.validate() + scalableMatrixWithUnitPricing.validate() } - override fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) { - newSubscriptionScalableMatrixWithTieredPricing.validate() + scalableMatrixWithTieredPricing.validate() } - override fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk ) { - newSubscriptionCumulativeGroupedBulk.validate() + cumulativeGroupedBulk.validate() } - override fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage ) { - newSubscriptionMaxGroupTieredPackage.validate() + maxGroupTieredPackage.validate() } - override fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ) { - newSubscriptionGroupedWithMeteredMinimum.validate() + groupedWithMeteredMinimum.validate() } - override fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName ) { - newSubscriptionMatrixWithDisplayName.validate() + matrixWithDisplayName.validate() } - override fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage ) { - newSubscriptionGroupedTieredPackage.validate() + groupedTieredPackage.validate() } } ) @@ -72574,115 +66967,83 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitNewSubscriptionUnit( - newSubscriptionUnit: NewSubscriptionUnitPrice - ) = newSubscriptionUnit.validity() - - override fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ) = newSubscriptionPackage.validity() - - override fun visitNewSubscriptionMatrix( - newSubscriptionMatrix: NewSubscriptionMatrixPrice - ) = newSubscriptionMatrix.validity() - - override fun visitNewSubscriptionTiered( - newSubscriptionTiered: NewSubscriptionTieredPrice - ) = newSubscriptionTiered.validity() - - override fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = newSubscriptionTieredBps.validity() - - override fun visitNewSubscriptionBps( - newSubscriptionBps: NewSubscriptionBpsPrice - ) = newSubscriptionBps.validity() - - override fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ) = newSubscriptionBulkBps.validity() - - override fun visitNewSubscriptionBulk( - newSubscriptionBulk: NewSubscriptionBulkPrice - ) = newSubscriptionBulk.validity() - - override fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: - NewSubscriptionThresholdTotalAmountPrice - ) = newSubscriptionThresholdTotalAmount.validity() - - override fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = newSubscriptionTieredPackage.validity() - - override fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = newSubscriptionTieredWithMinimum.validity() - - override fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = newSubscriptionUnitWithPercent.validity() - - override fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: - NewSubscriptionPackageWithAllocationPrice - ) = newSubscriptionPackageWithAllocation.validity() - - override fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = newSubscriptionTierWithProration.validity() - - override fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = newSubscriptionUnitWithProration.validity() - - override fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = newSubscriptionGroupedAllocation.validity() - - override fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = newSubscriptionGroupedWithProratedMinimum.validity() - - override fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = newSubscriptionBulkWithProration.validity() - - override fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = newSubscriptionScalableMatrixWithUnitPricing.validity() - - override fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = newSubscriptionScalableMatrixWithTieredPricing.validity() - - override fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: - NewSubscriptionCumulativeGroupedBulkPrice - ) = newSubscriptionCumulativeGroupedBulk.validity() - - override fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: - NewSubscriptionMaxGroupTieredPackagePrice - ) = newSubscriptionMaxGroupTieredPackage.validity() - - override fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = newSubscriptionGroupedWithMeteredMinimum.validity() - - override fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: - NewSubscriptionMatrixWithDisplayNamePrice - ) = newSubscriptionMatrixWithDisplayName.validity() - - override fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: - NewSubscriptionGroupedTieredPackagePrice - ) = newSubscriptionGroupedTieredPackage.validity() + override fun 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 visitBulkBps(bulkBps: BulkBps) = bulkBps.validity() + + override fun visitBulk(bulk: Bulk) = bulk.validity() + + override fun visitThresholdTotalAmount( + thresholdTotalAmount: ThresholdTotalAmount + ) = thresholdTotalAmount.validity() + + override fun visitTieredPackage(tieredPackage: TieredPackage) = + tieredPackage.validity() + + override fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + tieredWithMinimum.validity() + + override fun visitUnitWithPercent(unitWithPercent: UnitWithPercent) = + unitWithPercent.validity() + + override fun visitPackageWithAllocation( + packageWithAllocation: PackageWithAllocation + ) = packageWithAllocation.validity() + + override fun visitTieredWithProration( + tieredWithProration: TieredWithProration + ) = tieredWithProration.validity() + + override fun visitUnitWithProration(unitWithProration: UnitWithProration) = + unitWithProration.validity() + + override fun visitGroupedAllocation(groupedAllocation: GroupedAllocation) = + groupedAllocation.validity() + + override fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = groupedWithProratedMinimum.validity() + + override fun visitBulkWithProration(bulkWithProration: BulkWithProration) = + bulkWithProration.validity() + + override fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = scalableMatrixWithUnitPricing.validity() + + override fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = scalableMatrixWithTieredPricing.validity() + + override fun visitCumulativeGroupedBulk( + cumulativeGroupedBulk: CumulativeGroupedBulk + ) = cumulativeGroupedBulk.validity() + + override fun visitMaxGroupTieredPackage( + maxGroupTieredPackage: MaxGroupTieredPackage + ) = maxGroupTieredPackage.validity() + + override fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = groupedWithMeteredMinimum.validity() + + override fun visitMatrixWithDisplayName( + matrixWithDisplayName: MatrixWithDisplayName + ) = matrixWithDisplayName.validity() + + override fun visitGroupedTieredPackage( + groupedTieredPackage: GroupedTieredPackage + ) = groupedTieredPackage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -72693,215 +67054,141 @@ private constructor( return true } - return /* spotless:off */ other is Price && newSubscriptionUnit == other.newSubscriptionUnit && newSubscriptionPackage == other.newSubscriptionPackage && newSubscriptionMatrix == other.newSubscriptionMatrix && newSubscriptionTiered == other.newSubscriptionTiered && newSubscriptionTieredBps == other.newSubscriptionTieredBps && newSubscriptionBps == other.newSubscriptionBps && newSubscriptionBulkBps == other.newSubscriptionBulkBps && newSubscriptionBulk == other.newSubscriptionBulk && newSubscriptionThresholdTotalAmount == other.newSubscriptionThresholdTotalAmount && newSubscriptionTieredPackage == other.newSubscriptionTieredPackage && newSubscriptionTieredWithMinimum == other.newSubscriptionTieredWithMinimum && newSubscriptionUnitWithPercent == other.newSubscriptionUnitWithPercent && newSubscriptionPackageWithAllocation == other.newSubscriptionPackageWithAllocation && newSubscriptionTierWithProration == other.newSubscriptionTierWithProration && newSubscriptionUnitWithProration == other.newSubscriptionUnitWithProration && newSubscriptionGroupedAllocation == other.newSubscriptionGroupedAllocation && newSubscriptionGroupedWithProratedMinimum == other.newSubscriptionGroupedWithProratedMinimum && newSubscriptionBulkWithProration == other.newSubscriptionBulkWithProration && newSubscriptionScalableMatrixWithUnitPricing == other.newSubscriptionScalableMatrixWithUnitPricing && newSubscriptionScalableMatrixWithTieredPricing == other.newSubscriptionScalableMatrixWithTieredPricing && newSubscriptionCumulativeGroupedBulk == other.newSubscriptionCumulativeGroupedBulk && newSubscriptionMaxGroupTieredPackage == other.newSubscriptionMaxGroupTieredPackage && newSubscriptionGroupedWithMeteredMinimum == other.newSubscriptionGroupedWithMeteredMinimum && newSubscriptionMatrixWithDisplayName == other.newSubscriptionMatrixWithDisplayName && newSubscriptionGroupedTieredPackage == other.newSubscriptionGroupedTieredPackage /* spotless:on */ + 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 /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(newSubscriptionUnit, newSubscriptionPackage, newSubscriptionMatrix, newSubscriptionTiered, newSubscriptionTieredBps, newSubscriptionBps, newSubscriptionBulkBps, newSubscriptionBulk, newSubscriptionThresholdTotalAmount, newSubscriptionTieredPackage, newSubscriptionTieredWithMinimum, newSubscriptionUnitWithPercent, newSubscriptionPackageWithAllocation, newSubscriptionTierWithProration, newSubscriptionUnitWithProration, newSubscriptionGroupedAllocation, newSubscriptionGroupedWithProratedMinimum, newSubscriptionBulkWithProration, newSubscriptionScalableMatrixWithUnitPricing, newSubscriptionScalableMatrixWithTieredPricing, newSubscriptionCumulativeGroupedBulk, newSubscriptionMaxGroupTieredPackage, newSubscriptionGroupedWithMeteredMinimum, newSubscriptionMatrixWithDisplayName, newSubscriptionGroupedTieredPackage) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unit, package_, matrix, tiered, tieredBps, bps, bulkBps, bulk, thresholdTotalAmount, tieredPackage, tieredWithMinimum, unitWithPercent, packageWithAllocation, tieredWithProration, unitWithProration, groupedAllocation, groupedWithProratedMinimum, bulkWithProration, scalableMatrixWithUnitPricing, scalableMatrixWithTieredPricing, cumulativeGroupedBulk, maxGroupTieredPackage, groupedWithMeteredMinimum, matrixWithDisplayName, groupedTieredPackage) /* spotless:on */ override fun toString(): String = when { - newSubscriptionUnit != null -> "Price{newSubscriptionUnit=$newSubscriptionUnit}" - newSubscriptionPackage != null -> - "Price{newSubscriptionPackage=$newSubscriptionPackage}" - newSubscriptionMatrix != null -> - "Price{newSubscriptionMatrix=$newSubscriptionMatrix}" - newSubscriptionTiered != null -> - "Price{newSubscriptionTiered=$newSubscriptionTiered}" - newSubscriptionTieredBps != null -> - "Price{newSubscriptionTieredBps=$newSubscriptionTieredBps}" - newSubscriptionBps != null -> "Price{newSubscriptionBps=$newSubscriptionBps}" - newSubscriptionBulkBps != null -> - "Price{newSubscriptionBulkBps=$newSubscriptionBulkBps}" - newSubscriptionBulk != null -> "Price{newSubscriptionBulk=$newSubscriptionBulk}" - newSubscriptionThresholdTotalAmount != null -> - "Price{newSubscriptionThresholdTotalAmount=$newSubscriptionThresholdTotalAmount}" - newSubscriptionTieredPackage != null -> - "Price{newSubscriptionTieredPackage=$newSubscriptionTieredPackage}" - newSubscriptionTieredWithMinimum != null -> - "Price{newSubscriptionTieredWithMinimum=$newSubscriptionTieredWithMinimum}" - newSubscriptionUnitWithPercent != null -> - "Price{newSubscriptionUnitWithPercent=$newSubscriptionUnitWithPercent}" - newSubscriptionPackageWithAllocation != null -> - "Price{newSubscriptionPackageWithAllocation=$newSubscriptionPackageWithAllocation}" - newSubscriptionTierWithProration != null -> - "Price{newSubscriptionTierWithProration=$newSubscriptionTierWithProration}" - newSubscriptionUnitWithProration != null -> - "Price{newSubscriptionUnitWithProration=$newSubscriptionUnitWithProration}" - newSubscriptionGroupedAllocation != null -> - "Price{newSubscriptionGroupedAllocation=$newSubscriptionGroupedAllocation}" - newSubscriptionGroupedWithProratedMinimum != null -> - "Price{newSubscriptionGroupedWithProratedMinimum=$newSubscriptionGroupedWithProratedMinimum}" - newSubscriptionBulkWithProration != null -> - "Price{newSubscriptionBulkWithProration=$newSubscriptionBulkWithProration}" - newSubscriptionScalableMatrixWithUnitPricing != null -> - "Price{newSubscriptionScalableMatrixWithUnitPricing=$newSubscriptionScalableMatrixWithUnitPricing}" - newSubscriptionScalableMatrixWithTieredPricing != null -> - "Price{newSubscriptionScalableMatrixWithTieredPricing=$newSubscriptionScalableMatrixWithTieredPricing}" - newSubscriptionCumulativeGroupedBulk != null -> - "Price{newSubscriptionCumulativeGroupedBulk=$newSubscriptionCumulativeGroupedBulk}" - newSubscriptionMaxGroupTieredPackage != null -> - "Price{newSubscriptionMaxGroupTieredPackage=$newSubscriptionMaxGroupTieredPackage}" - newSubscriptionGroupedWithMeteredMinimum != null -> - "Price{newSubscriptionGroupedWithMeteredMinimum=$newSubscriptionGroupedWithMeteredMinimum}" - newSubscriptionMatrixWithDisplayName != null -> - "Price{newSubscriptionMatrixWithDisplayName=$newSubscriptionMatrixWithDisplayName}" - newSubscriptionGroupedTieredPackage != null -> - "Price{newSubscriptionGroupedTieredPackage=$newSubscriptionGroupedTieredPackage}" + 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}" _json != null -> "Price{_unknown=$_json}" else -> throw IllegalStateException("Invalid Price") } companion object { - @JvmStatic - fun ofNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice) = - Price(newSubscriptionUnit = newSubscriptionUnit) + @JvmStatic fun ofUnit(unit: Unit) = Price(unit = unit) - @JvmStatic - fun ofNewSubscriptionPackage(newSubscriptionPackage: NewSubscriptionPackagePrice) = - Price(newSubscriptionPackage = newSubscriptionPackage) + @JvmStatic fun ofPackage(package_: Package) = Price(package_ = package_) - @JvmStatic - fun ofNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice) = - Price(newSubscriptionMatrix = newSubscriptionMatrix) + @JvmStatic fun ofMatrix(matrix: Matrix) = Price(matrix = matrix) - @JvmStatic - fun ofNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice) = - Price(newSubscriptionTiered = newSubscriptionTiered) + @JvmStatic fun ofTiered(tiered: Tiered) = Price(tiered = tiered) - @JvmStatic - fun ofNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ) = Price(newSubscriptionTieredBps = newSubscriptionTieredBps) + @JvmStatic fun ofTieredBps(tieredBps: TieredBps) = Price(tieredBps = tieredBps) - @JvmStatic - fun ofNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice) = - Price(newSubscriptionBps = newSubscriptionBps) + @JvmStatic fun ofBps(bps: Bps) = Price(bps = bps) - @JvmStatic - fun ofNewSubscriptionBulkBps(newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice) = - Price(newSubscriptionBulkBps = newSubscriptionBulkBps) + @JvmStatic fun ofBulkBps(bulkBps: BulkBps) = Price(bulkBps = bulkBps) - @JvmStatic - fun ofNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice) = - Price(newSubscriptionBulk = newSubscriptionBulk) + @JvmStatic fun ofBulk(bulk: Bulk) = Price(bulk = bulk) @JvmStatic - fun ofNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ) = Price(newSubscriptionThresholdTotalAmount = newSubscriptionThresholdTotalAmount) + fun ofThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount) = + Price(thresholdTotalAmount = thresholdTotalAmount) @JvmStatic - fun ofNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ) = Price(newSubscriptionTieredPackage = newSubscriptionTieredPackage) + fun ofTieredPackage(tieredPackage: TieredPackage) = + Price(tieredPackage = tieredPackage) @JvmStatic - fun ofNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ) = Price(newSubscriptionTieredWithMinimum = newSubscriptionTieredWithMinimum) + fun ofTieredWithMinimum(tieredWithMinimum: TieredWithMinimum) = + Price(tieredWithMinimum = tieredWithMinimum) @JvmStatic - fun ofNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ) = Price(newSubscriptionUnitWithPercent = newSubscriptionUnitWithPercent) + fun ofUnitWithPercent(unitWithPercent: UnitWithPercent) = + Price(unitWithPercent = unitWithPercent) @JvmStatic - fun ofNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ) = - Price( - newSubscriptionPackageWithAllocation = newSubscriptionPackageWithAllocation - ) + fun ofPackageWithAllocation(packageWithAllocation: PackageWithAllocation) = + Price(packageWithAllocation = packageWithAllocation) @JvmStatic - fun ofNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ) = Price(newSubscriptionTierWithProration = newSubscriptionTierWithProration) + fun ofTieredWithProration(tieredWithProration: TieredWithProration) = + Price(tieredWithProration = tieredWithProration) @JvmStatic - fun ofNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ) = Price(newSubscriptionUnitWithProration = newSubscriptionUnitWithProration) + fun ofUnitWithProration(unitWithProration: UnitWithProration) = + Price(unitWithProration = unitWithProration) @JvmStatic - fun ofNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ) = Price(newSubscriptionGroupedAllocation = newSubscriptionGroupedAllocation) + fun ofGroupedAllocation(groupedAllocation: GroupedAllocation) = + Price(groupedAllocation = groupedAllocation) @JvmStatic - fun ofNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = - Price( - newSubscriptionGroupedWithProratedMinimum = - newSubscriptionGroupedWithProratedMinimum - ) + fun ofGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum + ) = Price(groupedWithProratedMinimum = groupedWithProratedMinimum) @JvmStatic - fun ofNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ) = Price(newSubscriptionBulkWithProration = newSubscriptionBulkWithProration) + fun ofBulkWithProration(bulkWithProration: BulkWithProration) = + Price(bulkWithProration = bulkWithProration) @JvmStatic - fun ofNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice - ) = - Price( - newSubscriptionScalableMatrixWithUnitPricing = - newSubscriptionScalableMatrixWithUnitPricing - ) + fun ofScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing + ) = Price(scalableMatrixWithUnitPricing = scalableMatrixWithUnitPricing) @JvmStatic - fun ofNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice - ) = - Price( - newSubscriptionScalableMatrixWithTieredPricing = - newSubscriptionScalableMatrixWithTieredPricing - ) + fun ofScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing + ) = Price(scalableMatrixWithTieredPricing = scalableMatrixWithTieredPricing) @JvmStatic - fun ofNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ) = - Price( - newSubscriptionCumulativeGroupedBulk = newSubscriptionCumulativeGroupedBulk - ) + fun ofCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk) = + Price(cumulativeGroupedBulk = cumulativeGroupedBulk) @JvmStatic - fun ofNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ) = - Price( - newSubscriptionMaxGroupTieredPackage = newSubscriptionMaxGroupTieredPackage - ) + fun ofMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage) = + Price(maxGroupTieredPackage = maxGroupTieredPackage) @JvmStatic - fun ofNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = - Price( - newSubscriptionGroupedWithMeteredMinimum = - newSubscriptionGroupedWithMeteredMinimum - ) + fun ofGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum + ) = Price(groupedWithMeteredMinimum = groupedWithMeteredMinimum) @JvmStatic - fun ofNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ) = - Price( - newSubscriptionMatrixWithDisplayName = newSubscriptionMatrixWithDisplayName - ) + fun ofMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName) = + Price(matrixWithDisplayName = matrixWithDisplayName) @JvmStatic - fun ofNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ) = Price(newSubscriptionGroupedTieredPackage = newSubscriptionGroupedTieredPackage) + fun ofGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage) = + Price(groupedTieredPackage = groupedTieredPackage) } /** @@ -72909,99 +67196,63 @@ private constructor( */ interface Visitor { - fun visitNewSubscriptionUnit(newSubscriptionUnit: NewSubscriptionUnitPrice): T + fun visitUnit(unit: Unit): T - fun visitNewSubscriptionPackage( - newSubscriptionPackage: NewSubscriptionPackagePrice - ): T + fun visitPackage(package_: Package): T - fun visitNewSubscriptionMatrix(newSubscriptionMatrix: NewSubscriptionMatrixPrice): T + fun visitMatrix(matrix: Matrix): T - fun visitNewSubscriptionTiered(newSubscriptionTiered: NewSubscriptionTieredPrice): T + fun visitTiered(tiered: Tiered): T - fun visitNewSubscriptionTieredBps( - newSubscriptionTieredBps: NewSubscriptionTieredBpsPrice - ): T + fun visitTieredBps(tieredBps: TieredBps): T - fun visitNewSubscriptionBps(newSubscriptionBps: NewSubscriptionBpsPrice): T + fun visitBps(bps: Bps): T - fun visitNewSubscriptionBulkBps( - newSubscriptionBulkBps: NewSubscriptionBulkBpsPrice - ): T + fun visitBulkBps(bulkBps: BulkBps): T - fun visitNewSubscriptionBulk(newSubscriptionBulk: NewSubscriptionBulkPrice): T + fun visitBulk(bulk: Bulk): T - fun visitNewSubscriptionThresholdTotalAmount( - newSubscriptionThresholdTotalAmount: NewSubscriptionThresholdTotalAmountPrice - ): T + fun visitThresholdTotalAmount(thresholdTotalAmount: ThresholdTotalAmount): T - fun visitNewSubscriptionTieredPackage( - newSubscriptionTieredPackage: NewSubscriptionTieredPackagePrice - ): T + fun visitTieredPackage(tieredPackage: TieredPackage): T - fun visitNewSubscriptionTieredWithMinimum( - newSubscriptionTieredWithMinimum: NewSubscriptionTieredWithMinimumPrice - ): T + fun visitTieredWithMinimum(tieredWithMinimum: TieredWithMinimum): T - fun visitNewSubscriptionUnitWithPercent( - newSubscriptionUnitWithPercent: NewSubscriptionUnitWithPercentPrice - ): T + fun visitUnitWithPercent(unitWithPercent: UnitWithPercent): T - fun visitNewSubscriptionPackageWithAllocation( - newSubscriptionPackageWithAllocation: NewSubscriptionPackageWithAllocationPrice - ): T + fun visitPackageWithAllocation(packageWithAllocation: PackageWithAllocation): T - fun visitNewSubscriptionTierWithProration( - newSubscriptionTierWithProration: NewSubscriptionTierWithProrationPrice - ): T + fun visitTieredWithProration(tieredWithProration: TieredWithProration): T - fun visitNewSubscriptionUnitWithProration( - newSubscriptionUnitWithProration: NewSubscriptionUnitWithProrationPrice - ): T + fun visitUnitWithProration(unitWithProration: UnitWithProration): T - fun visitNewSubscriptionGroupedAllocation( - newSubscriptionGroupedAllocation: NewSubscriptionGroupedAllocationPrice - ): T + fun visitGroupedAllocation(groupedAllocation: GroupedAllocation): T - fun visitNewSubscriptionGroupedWithProratedMinimum( - newSubscriptionGroupedWithProratedMinimum: - NewSubscriptionGroupedWithProratedMinimumPrice + fun visitGroupedWithProratedMinimum( + groupedWithProratedMinimum: GroupedWithProratedMinimum ): T - fun visitNewSubscriptionBulkWithProration( - newSubscriptionBulkWithProration: NewSubscriptionBulkWithProrationPrice - ): T + fun visitBulkWithProration(bulkWithProration: BulkWithProration): T - fun visitNewSubscriptionScalableMatrixWithUnitPricing( - newSubscriptionScalableMatrixWithUnitPricing: - NewSubscriptionScalableMatrixWithUnitPricingPrice + fun visitScalableMatrixWithUnitPricing( + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ): T - fun visitNewSubscriptionScalableMatrixWithTieredPricing( - newSubscriptionScalableMatrixWithTieredPricing: - NewSubscriptionScalableMatrixWithTieredPricingPrice + fun visitScalableMatrixWithTieredPricing( + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ): T - fun visitNewSubscriptionCumulativeGroupedBulk( - newSubscriptionCumulativeGroupedBulk: NewSubscriptionCumulativeGroupedBulkPrice - ): T + fun visitCumulativeGroupedBulk(cumulativeGroupedBulk: CumulativeGroupedBulk): T - fun visitNewSubscriptionMaxGroupTieredPackage( - newSubscriptionMaxGroupTieredPackage: NewSubscriptionMaxGroupTieredPackagePrice - ): T + fun visitMaxGroupTieredPackage(maxGroupTieredPackage: MaxGroupTieredPackage): T - fun visitNewSubscriptionGroupedWithMeteredMinimum( - newSubscriptionGroupedWithMeteredMinimum: - NewSubscriptionGroupedWithMeteredMinimumPrice + fun visitGroupedWithMeteredMinimum( + groupedWithMeteredMinimum: GroupedWithMeteredMinimum ): T - fun visitNewSubscriptionMatrixWithDisplayName( - newSubscriptionMatrixWithDisplayName: NewSubscriptionMatrixWithDisplayNamePrice - ): T + fun visitMatrixWithDisplayName(matrixWithDisplayName: MatrixWithDisplayName): T - fun visitNewSubscriptionGroupedTieredPackage( - newSubscriptionGroupedTieredPackage: NewSubscriptionGroupedTieredPackagePrice - ): T + fun visitGroupedTieredPackage(groupedTieredPackage: GroupedTieredPackage): T /** * Maps an unknown variant of [Price] to a value of type [T]. @@ -73027,221 +67278,138 @@ private constructor( when (modelType) { "unit" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionUnit = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unit = it, _json = json) + } ?: Price(_json = json) } "package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(package_ = it, _json = json) + } ?: Price(_json = json) } "matrix" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionMatrix = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(matrix = it, _json = json) + } ?: Price(_json = json) } "tiered" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTiered = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tiered = it, _json = json) + } ?: Price(_json = json) } "tiered_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredBps = it, _json = json) + } ?: Price(_json = json) } "bps" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bps = it, _json = json) + } ?: Price(_json = json) } "bulk_bps" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionBulkBps = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkBps = it, _json = json) + } ?: Price(_json = json) } "bulk" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { Price(newSubscriptionBulk = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulk = it, _json = json) + } ?: Price(_json = json) } "threshold_total_amount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionThresholdTotalAmount = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(thresholdTotalAmount = it, _json = json) } + ?: Price(_json = json) } "tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredPackage = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredPackage = it, _json = json) + } ?: Price(_json = json) } "tiered_with_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTieredWithMinimum = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(tieredWithMinimum = it, _json = json) + } ?: Price(_json = json) } "unit_with_percent" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionUnitWithPercent = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithPercent = it, _json = json) + } ?: Price(_json = json) } "package_with_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionPackageWithAllocation = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(packageWithAllocation = it, _json = json) } + ?: Price(_json = json) } "tiered_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionTierWithProration = it, _json = json) } + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(tieredWithProration = it, _json = json) } ?: Price(_json = json) } "unit_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionUnitWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(unitWithProration = it, _json = json) + } ?: Price(_json = json) } "grouped_allocation" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionGroupedAllocation = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(groupedAllocation = it, _json = json) + } ?: Price(_json = json) } "grouped_with_prorated_minimum" -> { return tryDeserialize( node, - jacksonTypeRef(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionGroupedWithProratedMinimum = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(groupedWithProratedMinimum = it, _json = json) } + ?: Price(_json = json) } "bulk_with_proration" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Price(newSubscriptionBulkWithProration = it, _json = json) } - ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Price(bulkWithProration = it, _json = json) + } ?: Price(_json = json) } "scalable_matrix_with_unit_pricing" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithUnitPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionScalableMatrixWithUnitPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithUnitPricing = it, _json = json) } + ?: Price(_json = json) } "scalable_matrix_with_tiered_pricing" -> { return tryDeserialize( node, - jacksonTypeRef< - NewSubscriptionScalableMatrixWithTieredPricingPrice - >(), + jacksonTypeRef(), ) - ?.let { - Price( - newSubscriptionScalableMatrixWithTieredPricing = it, - _json = json, - ) - } ?: Price(_json = json) + ?.let { Price(scalableMatrixWithTieredPricing = it, _json = json) } + ?: Price(_json = json) } "cumulative_grouped_bulk" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionCumulativeGroupedBulk = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(cumulativeGroupedBulk = it, _json = json) } + ?: Price(_json = json) } "max_group_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionMaxGroupTieredPackage = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(maxGroupTieredPackage = it, _json = json) } + ?: Price(_json = json) } "grouped_with_metered_minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price( - newSubscriptionGroupedWithMeteredMinimum = it, - _json = json, - ) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedWithMeteredMinimum = it, _json = json) } + ?: Price(_json = json) } "matrix_with_display_name" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionMatrixWithDisplayName = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(matrixWithDisplayName = it, _json = json) } + ?: Price(_json = json) } "grouped_tiered_package" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - Price(newSubscriptionGroupedTieredPackage = it, _json = json) - } ?: Price(_json = json) + return tryDeserialize(node, jacksonTypeRef()) + ?.let { Price(groupedTieredPackage = it, _json = json) } + ?: Price(_json = json) } } @@ -73257,71 +67425,58 @@ private constructor( provider: SerializerProvider, ) { when { - value.newSubscriptionUnit != null -> - generator.writeObject(value.newSubscriptionUnit) - value.newSubscriptionPackage != null -> - generator.writeObject(value.newSubscriptionPackage) - value.newSubscriptionMatrix != null -> - generator.writeObject(value.newSubscriptionMatrix) - value.newSubscriptionTiered != null -> - generator.writeObject(value.newSubscriptionTiered) - value.newSubscriptionTieredBps != null -> - generator.writeObject(value.newSubscriptionTieredBps) - value.newSubscriptionBps != null -> - generator.writeObject(value.newSubscriptionBps) - value.newSubscriptionBulkBps != null -> - generator.writeObject(value.newSubscriptionBulkBps) - value.newSubscriptionBulk != null -> - generator.writeObject(value.newSubscriptionBulk) - value.newSubscriptionThresholdTotalAmount != null -> - generator.writeObject(value.newSubscriptionThresholdTotalAmount) - value.newSubscriptionTieredPackage != null -> - generator.writeObject(value.newSubscriptionTieredPackage) - value.newSubscriptionTieredWithMinimum != null -> - generator.writeObject(value.newSubscriptionTieredWithMinimum) - value.newSubscriptionUnitWithPercent != null -> - generator.writeObject(value.newSubscriptionUnitWithPercent) - value.newSubscriptionPackageWithAllocation != null -> - generator.writeObject(value.newSubscriptionPackageWithAllocation) - value.newSubscriptionTierWithProration != null -> - generator.writeObject(value.newSubscriptionTierWithProration) - value.newSubscriptionUnitWithProration != null -> - generator.writeObject(value.newSubscriptionUnitWithProration) - value.newSubscriptionGroupedAllocation != null -> - generator.writeObject(value.newSubscriptionGroupedAllocation) - value.newSubscriptionGroupedWithProratedMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithProratedMinimum) - value.newSubscriptionBulkWithProration != null -> - generator.writeObject(value.newSubscriptionBulkWithProration) - value.newSubscriptionScalableMatrixWithUnitPricing != null -> - generator.writeObject( - value.newSubscriptionScalableMatrixWithUnitPricing - ) - value.newSubscriptionScalableMatrixWithTieredPricing != null -> - generator.writeObject( - value.newSubscriptionScalableMatrixWithTieredPricing - ) - value.newSubscriptionCumulativeGroupedBulk != null -> - generator.writeObject(value.newSubscriptionCumulativeGroupedBulk) - value.newSubscriptionMaxGroupTieredPackage != null -> - generator.writeObject(value.newSubscriptionMaxGroupTieredPackage) - value.newSubscriptionGroupedWithMeteredMinimum != null -> - generator.writeObject(value.newSubscriptionGroupedWithMeteredMinimum) - value.newSubscriptionMatrixWithDisplayName != null -> - generator.writeObject(value.newSubscriptionMatrixWithDisplayName) - value.newSubscriptionGroupedTieredPackage != null -> - generator.writeObject(value.newSubscriptionGroupedTieredPackage) + 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._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid Price") } } } - class NewSubscriptionUnitPrice + class Unit private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitConfig: JsonField, private val billableMetricId: JsonField, @@ -73348,7 +67503,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -73429,11 +67584,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -73574,16 +67733,6 @@ private constructor( */ @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]. * @@ -73729,14 +67878,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitPrice]. + * Returns a mutable builder for constructing an instance of [Unit]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` @@ -73744,12 +67891,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitPrice]. */ + /** A builder for [Unit]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit") private var name: JsonField? = null private var unitConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -73769,27 +67916,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionUnitPrice: NewSubscriptionUnitPrice) = apply { - cadence = newSubscriptionUnitPrice.cadence - itemId = newSubscriptionUnitPrice.itemId - modelType = newSubscriptionUnitPrice.modelType - name = newSubscriptionUnitPrice.name - unitConfig = newSubscriptionUnitPrice.unitConfig - billableMetricId = newSubscriptionUnitPrice.billableMetricId - billedInAdvance = newSubscriptionUnitPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitPrice.conversionRate - currency = newSubscriptionUnitPrice.currency - externalPriceId = newSubscriptionUnitPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitPrice.metadata - referenceId = newSubscriptionUnitPrice.referenceId - additionalProperties = - newSubscriptionUnitPrice.additionalProperties.toMutableMap() + internal fun from(unit: Unit) = apply { + cadence = unit.cadence + itemId = unit.itemId + modelType = unit.modelType + name = unit.name + unitConfig = unit.unitConfig + billableMetricId = unit.billableMetricId + billedInAdvance = unit.billedInAdvance + billingCycleConfiguration = unit.billingCycleConfiguration + conversionRate = unit.conversionRate + currency = unit.currency + externalPriceId = unit.externalPriceId + fixedPriceQuantity = unit.fixedPriceQuantity + invoiceGroupingKey = unit.invoiceGroupingKey + invoicingCycleConfiguration = unit.invoicingCycleConfiguration + metadata = unit.metadata + referenceId = unit.referenceId + additionalProperties = unit.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -73816,18 +67960,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -74161,7 +68306,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitPrice]. + * Returns an immutable instance of [Unit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -74169,18 +68314,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitPrice = - NewSubscriptionUnitPrice( + fun build(): Unit = + Unit( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitConfig", unitConfig), billableMetricId, @@ -74200,14 +68344,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitPrice = apply { + fun validate(): Unit = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitConfig().validate() billableMetricId() @@ -74242,7 +68390,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -74416,135 +68564,6 @@ private constructor( 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 UNIT = of("unit") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT - } - - /** - * 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 { - UNIT, - /** - * 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) { - UNIT -> Value.UNIT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT -> Known.UNIT - 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 UnitConfig private constructor( private val unitAmount: JsonField, @@ -75554,7 +69573,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Unit && 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 && currency == other.currency && 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 */ @@ -75564,14 +69583,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Unit{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitConfig=$unitConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionPackagePrice + class Package private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageConfig: JsonField, private val billableMetricId: JsonField, @@ -75598,7 +69617,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -75679,11 +69698,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -75824,16 +69847,6 @@ private constructor( */ @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]. * @@ -75979,14 +69992,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionPackagePrice]. + * Returns a mutable builder for constructing an instance of [Package]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` @@ -75994,12 +70005,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionPackagePrice]. */ + /** A builder for [Package]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package") private var name: JsonField? = null private var packageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -76019,29 +70030,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionPackagePrice: NewSubscriptionPackagePrice) = - apply { - cadence = newSubscriptionPackagePrice.cadence - itemId = newSubscriptionPackagePrice.itemId - modelType = newSubscriptionPackagePrice.modelType - name = newSubscriptionPackagePrice.name - packageConfig = newSubscriptionPackagePrice.packageConfig - billableMetricId = newSubscriptionPackagePrice.billableMetricId - billedInAdvance = newSubscriptionPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionPackagePrice.conversionRate - currency = newSubscriptionPackagePrice.currency - externalPriceId = newSubscriptionPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionPackagePrice.metadata - referenceId = newSubscriptionPackagePrice.referenceId - additionalProperties = - newSubscriptionPackagePrice.additionalProperties.toMutableMap() - } + internal fun from(package_: Package) = apply { + cadence = package_.cadence + itemId = package_.itemId + modelType = package_.modelType + name = package_.name + packageConfig = package_.packageConfig + billableMetricId = package_.billableMetricId + billedInAdvance = package_.billedInAdvance + billingCycleConfiguration = package_.billingCycleConfiguration + conversionRate = package_.conversionRate + currency = package_.currency + externalPriceId = package_.externalPriceId + fixedPriceQuantity = package_.fixedPriceQuantity + invoiceGroupingKey = package_.invoiceGroupingKey + invoicingCycleConfiguration = package_.invoicingCycleConfiguration + metadata = package_.metadata + referenceId = package_.referenceId + additionalProperties = package_.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -76067,18 +70074,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -76413,7 +70421,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionPackagePrice]. + * Returns an immutable instance of [Package]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -76421,18 +70429,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionPackagePrice = - NewSubscriptionPackagePrice( + fun build(): Package = + Package( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("packageConfig", packageConfig), billableMetricId, @@ -76452,14 +70459,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionPackagePrice = apply { + fun validate(): Package = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageConfig().validate() billableMetricId() @@ -76494,7 +70505,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (packageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -76668,135 +70679,6 @@ private constructor( 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 PACKAGE = of("package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE - } - - /** - * 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 { - PACKAGE, - /** - * 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) { - PACKAGE -> Value.PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE -> Known.PACKAGE - 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 PackageConfig private constructor( private val packageAmount: JsonField, @@ -77857,7 +71739,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Package && 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 && currency == other.currency && 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 */ @@ -77867,15 +71749,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Package{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageConfig=$packageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMatrixPrice + class Matrix private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -77904,7 +71786,7 @@ private constructor( matrixConfig: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -77989,11 +71871,15 @@ private constructor( fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -78137,16 +72023,6 @@ private constructor( @ExcludeMissing fun _matrixConfig(): JsonField = matrixConfig - /** - * 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]. * @@ -78282,28 +72158,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMatrixPrice]. + * Returns a mutable builder for constructing an instance of [Matrix]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMatrixPrice]. */ + /** A builder for [Matrix]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null private var matrixConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -78322,29 +72196,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionMatrixPrice: NewSubscriptionMatrixPrice) = - apply { - cadence = newSubscriptionMatrixPrice.cadence - itemId = newSubscriptionMatrixPrice.itemId - matrixConfig = newSubscriptionMatrixPrice.matrixConfig - modelType = newSubscriptionMatrixPrice.modelType - name = newSubscriptionMatrixPrice.name - billableMetricId = newSubscriptionMatrixPrice.billableMetricId - billedInAdvance = newSubscriptionMatrixPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixPrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixPrice.conversionRate - currency = newSubscriptionMatrixPrice.currency - externalPriceId = newSubscriptionMatrixPrice.externalPriceId - fixedPriceQuantity = newSubscriptionMatrixPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionMatrixPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionMatrixPrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixPrice.metadata - referenceId = newSubscriptionMatrixPrice.referenceId - additionalProperties = - newSubscriptionMatrixPrice.additionalProperties.toMutableMap() - } + internal fun from(matrix: Matrix) = apply { + cadence = matrix.cadence + itemId = matrix.itemId + matrixConfig = matrix.matrixConfig + modelType = matrix.modelType + name = matrix.name + billableMetricId = matrix.billableMetricId + billedInAdvance = matrix.billedInAdvance + billingCycleConfiguration = matrix.billingCycleConfiguration + conversionRate = matrix.conversionRate + currency = matrix.currency + externalPriceId = matrix.externalPriceId + fixedPriceQuantity = matrix.fixedPriceQuantity + invoiceGroupingKey = matrix.invoiceGroupingKey + invoicingCycleConfiguration = matrix.invoicingCycleConfiguration + metadata = matrix.metadata + referenceId = matrix.referenceId + additionalProperties = matrix.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -78384,18 +72254,19 @@ private constructor( this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -78716,7 +72587,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMatrixPrice]. + * Returns an immutable instance of [Matrix]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -78725,18 +72596,17 @@ private constructor( * .cadence() * .itemId() * .matrixConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMatrixPrice = - NewSubscriptionMatrixPrice( + fun build(): Matrix = + Matrix( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired("matrixConfig", matrixConfig), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -78755,7 +72625,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMatrixPrice = apply { + fun validate(): Matrix = apply { if (validated) { return@apply } @@ -78763,7 +72633,11 @@ private constructor( cadence().validate() itemId() matrixConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -78798,7 +72672,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("matrix")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -79516,135 +73390,6 @@ private constructor( "MatrixConfig{defaultUnitAmount=$defaultUnitAmount, dimensions=$dimensions, matrixValues=$matrixValues, additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX = of("matrix") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX - } - - /** - * 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 { - MATRIX, - /** - * 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) { - MATRIX -> Value.MATRIX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX -> Known.MATRIX - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -80483,7 +74228,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Matrix && 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 && currency == other.currency && 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 */ @@ -80493,14 +74238,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixPrice{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Matrix{cadence=$cadence, itemId=$itemId, matrixConfig=$matrixConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredPrice + class Tiered private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredConfig: JsonField, private val billableMetricId: JsonField, @@ -80527,7 +74272,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -80608,11 +74353,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -80753,16 +74502,6 @@ private constructor( */ @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]. * @@ -80908,14 +74647,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredPrice]. + * Returns a mutable builder for constructing an instance of [Tiered]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` @@ -80923,12 +74660,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredPrice]. */ + /** A builder for [Tiered]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered") private var name: JsonField? = null private var tieredConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -80948,29 +74685,25 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionTieredPrice: NewSubscriptionTieredPrice) = - apply { - cadence = newSubscriptionTieredPrice.cadence - itemId = newSubscriptionTieredPrice.itemId - modelType = newSubscriptionTieredPrice.modelType - name = newSubscriptionTieredPrice.name - tieredConfig = newSubscriptionTieredPrice.tieredConfig - billableMetricId = newSubscriptionTieredPrice.billableMetricId - billedInAdvance = newSubscriptionTieredPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPrice.conversionRate - currency = newSubscriptionTieredPrice.currency - externalPriceId = newSubscriptionTieredPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPrice.metadata - referenceId = newSubscriptionTieredPrice.referenceId - additionalProperties = - newSubscriptionTieredPrice.additionalProperties.toMutableMap() - } + internal fun from(tiered: Tiered) = apply { + cadence = tiered.cadence + itemId = tiered.itemId + modelType = tiered.modelType + name = tiered.name + tieredConfig = tiered.tieredConfig + billableMetricId = tiered.billableMetricId + billedInAdvance = tiered.billedInAdvance + billingCycleConfiguration = tiered.billingCycleConfiguration + conversionRate = tiered.conversionRate + currency = tiered.currency + externalPriceId = tiered.externalPriceId + fixedPriceQuantity = tiered.fixedPriceQuantity + invoiceGroupingKey = tiered.invoiceGroupingKey + invoicingCycleConfiguration = tiered.invoicingCycleConfiguration + metadata = tiered.metadata + referenceId = tiered.referenceId + additionalProperties = tiered.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -80996,18 +74729,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -81342,7 +75076,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredPrice]. + * Returns an immutable instance of [Tiered]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -81350,18 +75084,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredPrice = - NewSubscriptionTieredPrice( + fun build(): Tiered = + Tiered( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredConfig", tieredConfig), billableMetricId, @@ -81381,14 +75114,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredPrice = apply { + fun validate(): Tiered = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredConfig().validate() billableMetricId() @@ -81423,7 +75160,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -81597,135 +75334,6 @@ private constructor( 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 = of("tiered") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED - } - - /** - * 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, - /** - * 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 -> Value.TIERED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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 -> Known.TIERED - 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 TieredConfig private constructor( private val tiers: JsonField>, @@ -83027,7 +76635,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tiered && 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 && currency == other.currency && 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 */ @@ -83037,14 +76645,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Tiered{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredConfig=$tieredConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredBpsPrice + class TieredBps private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredBpsConfig: JsonField, private val billableMetricId: JsonField, @@ -83071,7 +76679,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -83152,11 +76760,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -83298,16 +76910,6 @@ private constructor( */ @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]. * @@ -83453,14 +77055,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredBpsPrice]. + * Returns a mutable builder for constructing an instance of [TieredBps]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` @@ -83468,12 +77068,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredBpsPrice]. */ + /** A builder for [TieredBps]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_bps") private var name: JsonField? = null private var tieredBpsConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -83493,29 +77093,24 @@ private constructor( 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 - currency = newSubscriptionTieredBpsPrice.currency - externalPriceId = newSubscriptionTieredBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredBpsPrice.metadata - referenceId = newSubscriptionTieredBpsPrice.referenceId - additionalProperties = - newSubscriptionTieredBpsPrice.additionalProperties.toMutableMap() + internal fun from(tieredBps: TieredBps) = apply { + cadence = tieredBps.cadence + itemId = tieredBps.itemId + modelType = tieredBps.modelType + name = tieredBps.name + tieredBpsConfig = tieredBps.tieredBpsConfig + billableMetricId = tieredBps.billableMetricId + billedInAdvance = tieredBps.billedInAdvance + billingCycleConfiguration = tieredBps.billingCycleConfiguration + conversionRate = tieredBps.conversionRate + currency = tieredBps.currency + externalPriceId = tieredBps.externalPriceId + fixedPriceQuantity = tieredBps.fixedPriceQuantity + invoiceGroupingKey = tieredBps.invoiceGroupingKey + invoicingCycleConfiguration = tieredBps.invoicingCycleConfiguration + metadata = tieredBps.metadata + referenceId = tieredBps.referenceId + additionalProperties = tieredBps.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -83542,18 +77137,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -83888,7 +77484,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredBpsPrice]. + * Returns an immutable instance of [TieredBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -83896,18 +77492,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredBpsConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredBpsPrice = - NewSubscriptionTieredBpsPrice( + fun build(): TieredBps = + TieredBps( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredBpsConfig", tieredBpsConfig), billableMetricId, @@ -83927,14 +77522,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredBpsPrice = apply { + fun validate(): TieredBps = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredBpsConfig().validate() billableMetricId() @@ -83969,7 +77568,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -84143,135 +77742,6 @@ private constructor( 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() - } - class TieredBpsConfig private constructor( private val tiers: JsonField>, @@ -85615,7 +79085,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTieredBpsPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredBps && 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 && currency == other.currency && 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 */ @@ -85625,15 +79095,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredBps{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBpsPrice + class Bps private constructor( private val bpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -85662,7 +79132,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -85747,11 +79217,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -85895,16 +79369,6 @@ private constructor( */ @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]. * @@ -86040,28 +79504,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBpsPrice]. + * Returns a mutable builder for constructing an instance of [Bps]. * * The following fields are required: * ```java * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBpsPrice]. */ + /** A builder for [Bps]. */ 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 modelType: JsonValue = JsonValue.from("bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -86080,27 +79542,24 @@ private constructor( 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 - currency = newSubscriptionBpsPrice.currency - externalPriceId = newSubscriptionBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBpsPrice.metadata - referenceId = newSubscriptionBpsPrice.referenceId - additionalProperties = - newSubscriptionBpsPrice.additionalProperties.toMutableMap() + internal fun from(bps: Bps) = apply { + bpsConfig = bps.bpsConfig + cadence = bps.cadence + itemId = bps.itemId + modelType = bps.modelType + name = bps.name + billableMetricId = bps.billableMetricId + billedInAdvance = bps.billedInAdvance + billingCycleConfiguration = bps.billingCycleConfiguration + conversionRate = bps.conversionRate + currency = bps.currency + externalPriceId = bps.externalPriceId + fixedPriceQuantity = bps.fixedPriceQuantity + invoiceGroupingKey = bps.invoiceGroupingKey + invoicingCycleConfiguration = bps.invoicingCycleConfiguration + metadata = bps.metadata + referenceId = bps.referenceId + additionalProperties = bps.additionalProperties.toMutableMap() } fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) @@ -86140,18 +79599,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -86472,7 +79932,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBpsPrice]. + * Returns an immutable instance of [Bps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -86481,18 +79941,17 @@ private constructor( * .bpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBpsPrice = - NewSubscriptionBpsPrice( + fun build(): Bps = + Bps( checkRequired("bpsConfig", bpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -86511,7 +79970,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBpsPrice = apply { + fun validate(): Bps = apply { if (validated) { return@apply } @@ -86519,7 +79978,11 @@ private constructor( bpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -86554,7 +80017,7 @@ private constructor( (bpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -86945,135 +80408,6 @@ private constructor( 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -87912,7 +81246,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionBpsPrice && bpsConfig == other.bpsConfig && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bps && 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 && currency == other.currency && 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 */ @@ -87922,15 +81256,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bps{bpsConfig=$bpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkBpsPrice + class BulkBps private constructor( private val bulkBpsConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -87959,7 +81293,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -88044,11 +81378,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -88192,16 +81530,6 @@ private constructor( */ @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]. * @@ -88337,28 +81665,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkBpsPrice]. + * Returns a mutable builder for constructing an instance of [BulkBps]. * * The following fields are required: * ```java * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkBpsPrice]. */ + /** A builder for [BulkBps]. */ class Builder internal constructor() { private var bulkBpsConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_bps") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -88377,29 +81703,25 @@ 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 - currency = newSubscriptionBulkBpsPrice.currency - externalPriceId = newSubscriptionBulkBpsPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkBpsPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkBpsPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkBpsPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkBpsPrice.metadata - referenceId = newSubscriptionBulkBpsPrice.referenceId - additionalProperties = - newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() - } + internal fun from(bulkBps: BulkBps) = apply { + bulkBpsConfig = bulkBps.bulkBpsConfig + cadence = bulkBps.cadence + itemId = bulkBps.itemId + modelType = bulkBps.modelType + name = bulkBps.name + billableMetricId = bulkBps.billableMetricId + billedInAdvance = bulkBps.billedInAdvance + billingCycleConfiguration = bulkBps.billingCycleConfiguration + conversionRate = bulkBps.conversionRate + currency = bulkBps.currency + externalPriceId = bulkBps.externalPriceId + fixedPriceQuantity = bulkBps.fixedPriceQuantity + invoiceGroupingKey = bulkBps.invoiceGroupingKey + invoicingCycleConfiguration = bulkBps.invoicingCycleConfiguration + metadata = bulkBps.metadata + referenceId = bulkBps.referenceId + additionalProperties = bulkBps.additionalProperties.toMutableMap() + } fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = bulkBpsConfig(JsonField.of(bulkBpsConfig)) @@ -88439,18 +81761,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_bps") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -88771,7 +82094,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkBpsPrice]. + * Returns an immutable instance of [BulkBps]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -88780,18 +82103,17 @@ private constructor( * .bulkBpsConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkBpsPrice = - NewSubscriptionBulkBpsPrice( + fun build(): BulkBps = + BulkBps( checkRequired("bulkBpsConfig", bulkBpsConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -88810,7 +82132,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkBpsPrice = apply { + fun validate(): BulkBps = apply { if (validated) { return@apply } @@ -88818,7 +82140,11 @@ private constructor( bulkBpsConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_bps")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -88853,7 +82179,7 @@ private constructor( (bulkBpsConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk_bps")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -89485,135 +82811,6 @@ private constructor( 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 BULK_BPS = of("bulk_bps") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_BPS - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK_BPS, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK_BPS -> Value.BULK_BPS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK_BPS -> Known.BULK_BPS - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -90452,7 +83649,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkBps && 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 && currency == other.currency && 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 */ @@ -90462,15 +83659,15 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkBps{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkPrice + class Bulk private constructor( private val bulkConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -90499,7 +83696,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -90584,11 +83781,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -90732,16 +83933,6 @@ private constructor( */ @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]. * @@ -90877,28 +84068,26 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkPrice]. + * Returns a mutable builder for constructing an instance of [Bulk]. * * The following fields are required: * ```java * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkPrice]. */ + /** A builder for [Bulk]. */ class Builder internal constructor() { private var bulkConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -90917,27 +84106,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(newSubscriptionBulkPrice: NewSubscriptionBulkPrice) = apply { - bulkConfig = newSubscriptionBulkPrice.bulkConfig - cadence = newSubscriptionBulkPrice.cadence - itemId = newSubscriptionBulkPrice.itemId - modelType = newSubscriptionBulkPrice.modelType - name = newSubscriptionBulkPrice.name - billableMetricId = newSubscriptionBulkPrice.billableMetricId - billedInAdvance = newSubscriptionBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkPrice.conversionRate - currency = newSubscriptionBulkPrice.currency - externalPriceId = newSubscriptionBulkPrice.externalPriceId - fixedPriceQuantity = newSubscriptionBulkPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionBulkPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkPrice.metadata - referenceId = newSubscriptionBulkPrice.referenceId - additionalProperties = - newSubscriptionBulkPrice.additionalProperties.toMutableMap() + internal fun from(bulk: Bulk) = apply { + bulkConfig = bulk.bulkConfig + cadence = bulk.cadence + itemId = bulk.itemId + modelType = bulk.modelType + name = bulk.name + billableMetricId = bulk.billableMetricId + billedInAdvance = bulk.billedInAdvance + billingCycleConfiguration = bulk.billingCycleConfiguration + conversionRate = bulk.conversionRate + currency = bulk.currency + externalPriceId = bulk.externalPriceId + fixedPriceQuantity = bulk.fixedPriceQuantity + invoiceGroupingKey = bulk.invoiceGroupingKey + invoicingCycleConfiguration = bulk.invoicingCycleConfiguration + metadata = bulk.metadata + referenceId = bulk.referenceId + additionalProperties = bulk.additionalProperties.toMutableMap() } fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) @@ -90977,18 +84163,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -91309,7 +84496,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkPrice]. + * Returns an immutable instance of [Bulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -91318,18 +84505,17 @@ private constructor( * .bulkConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkPrice = - NewSubscriptionBulkPrice( + fun build(): Bulk = + Bulk( checkRequired("bulkConfig", bulkConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -91348,7 +84534,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkPrice = apply { + fun validate(): Bulk = apply { if (validated) { return@apply } @@ -91356,7 +84542,11 @@ private constructor( bulkConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -91391,7 +84581,7 @@ private constructor( (bulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("bulk")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -91981,135 +85171,6 @@ private constructor( 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 BULK = of("bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BULK, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BULK -> Value.BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - BULK -> Known.BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -92948,7 +86009,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Bulk && 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 && currency == other.currency && 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 */ @@ -92958,14 +86019,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "Bulk{bulkConfig=$bulkConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionThresholdTotalAmountPrice + class ThresholdTotalAmount private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val thresholdTotalAmountConfig: JsonField, private val billableMetricId: JsonField, @@ -92992,7 +86053,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -93074,11 +86135,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -93220,16 +86285,6 @@ private constructor( */ @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]. * @@ -93377,13 +86432,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionThresholdTotalAmountPrice]. + * [ThresholdTotalAmount]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` @@ -93391,12 +86445,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionThresholdTotalAmountPrice]. */ + /** A builder for [ThresholdTotalAmount]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("threshold_total_amount") private var name: JsonField? = null private var thresholdTotalAmountConfig: JsonField? = null @@ -93417,34 +86471,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionThresholdTotalAmountPrice: - NewSubscriptionThresholdTotalAmountPrice - ) = apply { - cadence = newSubscriptionThresholdTotalAmountPrice.cadence - itemId = newSubscriptionThresholdTotalAmountPrice.itemId - modelType = newSubscriptionThresholdTotalAmountPrice.modelType - name = newSubscriptionThresholdTotalAmountPrice.name - thresholdTotalAmountConfig = - newSubscriptionThresholdTotalAmountPrice.thresholdTotalAmountConfig - billableMetricId = newSubscriptionThresholdTotalAmountPrice.billableMetricId - billedInAdvance = newSubscriptionThresholdTotalAmountPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.billingCycleConfiguration - conversionRate = newSubscriptionThresholdTotalAmountPrice.conversionRate - currency = newSubscriptionThresholdTotalAmountPrice.currency - externalPriceId = newSubscriptionThresholdTotalAmountPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionThresholdTotalAmountPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionThresholdTotalAmountPrice.invoiceGroupingKey + internal fun from(thresholdTotalAmount: ThresholdTotalAmount) = apply { + cadence = thresholdTotalAmount.cadence + itemId = thresholdTotalAmount.itemId + modelType = thresholdTotalAmount.modelType + name = thresholdTotalAmount.name + thresholdTotalAmountConfig = thresholdTotalAmount.thresholdTotalAmountConfig + billableMetricId = thresholdTotalAmount.billableMetricId + billedInAdvance = thresholdTotalAmount.billedInAdvance + billingCycleConfiguration = thresholdTotalAmount.billingCycleConfiguration + conversionRate = thresholdTotalAmount.conversionRate + currency = thresholdTotalAmount.currency + externalPriceId = thresholdTotalAmount.externalPriceId + fixedPriceQuantity = thresholdTotalAmount.fixedPriceQuantity + invoiceGroupingKey = thresholdTotalAmount.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionThresholdTotalAmountPrice.invoicingCycleConfiguration - metadata = newSubscriptionThresholdTotalAmountPrice.metadata - referenceId = newSubscriptionThresholdTotalAmountPrice.referenceId + thresholdTotalAmount.invoicingCycleConfiguration + metadata = thresholdTotalAmount.metadata + referenceId = thresholdTotalAmount.referenceId additionalProperties = - newSubscriptionThresholdTotalAmountPrice.additionalProperties - .toMutableMap() + thresholdTotalAmount.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -93471,18 +86517,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("threshold_total_amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -93819,7 +86866,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionThresholdTotalAmountPrice]. + * Returns an immutable instance of [ThresholdTotalAmount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -93827,18 +86874,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .thresholdTotalAmountConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionThresholdTotalAmountPrice = - NewSubscriptionThresholdTotalAmountPrice( + fun build(): ThresholdTotalAmount = + ThresholdTotalAmount( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("thresholdTotalAmountConfig", thresholdTotalAmountConfig), billableMetricId, @@ -93858,14 +86904,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { + fun validate(): ThresholdTotalAmount = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("threshold_total_amount")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() thresholdTotalAmountConfig().validate() billableMetricId() @@ -93900,7 +86950,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("threshold_total_amount")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (thresholdTotalAmountConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -94074,135 +87126,6 @@ private constructor( 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 THRESHOLD_TOTAL_AMOUNT = of("threshold_total_amount") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - THRESHOLD_TOTAL_AMOUNT - } - - /** - * 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 { - THRESHOLD_TOTAL_AMOUNT, - /** - * 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) { - THRESHOLD_TOTAL_AMOUNT -> Value.THRESHOLD_TOTAL_AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THRESHOLD_TOTAL_AMOUNT -> Known.THRESHOLD_TOTAL_AMOUNT - 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 ThresholdTotalAmountConfig @JsonCreator private constructor( @@ -95155,7 +88078,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ThresholdTotalAmount && 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 && currency == other.currency && 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 */ @@ -95165,14 +88088,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionThresholdTotalAmountPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ThresholdTotalAmount{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredPackagePrice + class TieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredPackageConfig: JsonField, private val billableMetricId: JsonField, @@ -95199,7 +88122,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -95280,11 +88203,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -95426,16 +88353,6 @@ private constructor( */ @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]. * @@ -95581,14 +88498,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredPackagePrice]. + * Returns a mutable builder for constructing an instance of [TieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` @@ -95596,12 +88511,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredPackagePrice]. */ + /** A builder for [TieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_package") private var name: JsonField? = null private var tieredPackageConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -95621,29 +88536,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionTieredPackagePrice: NewSubscriptionTieredPackagePrice - ) = apply { - cadence = newSubscriptionTieredPackagePrice.cadence - itemId = newSubscriptionTieredPackagePrice.itemId - modelType = newSubscriptionTieredPackagePrice.modelType - name = newSubscriptionTieredPackagePrice.name - tieredPackageConfig = newSubscriptionTieredPackagePrice.tieredPackageConfig - billableMetricId = newSubscriptionTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredPackagePrice.conversionRate - currency = newSubscriptionTieredPackagePrice.currency - externalPriceId = newSubscriptionTieredPackagePrice.externalPriceId - fixedPriceQuantity = newSubscriptionTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionTieredPackagePrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredPackagePrice.metadata - referenceId = newSubscriptionTieredPackagePrice.referenceId - additionalProperties = - newSubscriptionTieredPackagePrice.additionalProperties.toMutableMap() + internal fun from(tieredPackage: TieredPackage) = apply { + cadence = tieredPackage.cadence + itemId = tieredPackage.itemId + modelType = tieredPackage.modelType + name = tieredPackage.name + tieredPackageConfig = tieredPackage.tieredPackageConfig + billableMetricId = tieredPackage.billableMetricId + billedInAdvance = tieredPackage.billedInAdvance + billingCycleConfiguration = tieredPackage.billingCycleConfiguration + conversionRate = tieredPackage.conversionRate + currency = tieredPackage.currency + externalPriceId = tieredPackage.externalPriceId + fixedPriceQuantity = tieredPackage.fixedPriceQuantity + invoiceGroupingKey = tieredPackage.invoiceGroupingKey + invoicingCycleConfiguration = tieredPackage.invoicingCycleConfiguration + metadata = tieredPackage.metadata + referenceId = tieredPackage.referenceId + additionalProperties = tieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -95670,18 +88580,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -96017,7 +88928,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredPackagePrice]. + * Returns an immutable instance of [TieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -96025,18 +88936,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredPackageConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredPackagePrice = - NewSubscriptionTieredPackagePrice( + fun build(): TieredPackage = + TieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredPackageConfig", tieredPackageConfig), billableMetricId, @@ -96056,14 +88966,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredPackagePrice = apply { + fun validate(): TieredPackage = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredPackageConfig().validate() billableMetricId() @@ -96098,7 +89012,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("tiered_package")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (tieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -96272,135 +89186,6 @@ private constructor( 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_PACKAGE = of("tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_PACKAGE - } - - /** - * 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_PACKAGE, - /** - * 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_PACKAGE -> Value.TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_PACKAGE -> Known.TIERED_PACKAGE - 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 TieredPackageConfig @JsonCreator private constructor( @@ -97352,7 +90137,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredPackage && 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 && currency == other.currency && 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 */ @@ -97362,14 +90147,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredPackagePrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredPackage{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTieredWithMinimumPrice + class TieredWithMinimum private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithMinimumConfig: JsonField, private val billableMetricId: JsonField, @@ -97396,7 +90181,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -97477,11 +90262,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -97623,16 +90412,6 @@ private constructor( */ @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]. * @@ -97780,13 +90559,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTieredWithMinimumPrice]. + * [TieredWithMinimum]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` @@ -97794,12 +90572,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTieredWithMinimumPrice]. */ + /** A builder for [TieredWithMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_minimum") private var name: JsonField? = null private var tieredWithMinimumConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -97819,33 +90597,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionTieredWithMinimumPrice: NewSubscriptionTieredWithMinimumPrice - ) = apply { - cadence = newSubscriptionTieredWithMinimumPrice.cadence - itemId = newSubscriptionTieredWithMinimumPrice.itemId - modelType = newSubscriptionTieredWithMinimumPrice.modelType - name = newSubscriptionTieredWithMinimumPrice.name - tieredWithMinimumConfig = - newSubscriptionTieredWithMinimumPrice.tieredWithMinimumConfig - billableMetricId = newSubscriptionTieredWithMinimumPrice.billableMetricId - billedInAdvance = newSubscriptionTieredWithMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.billingCycleConfiguration - conversionRate = newSubscriptionTieredWithMinimumPrice.conversionRate - currency = newSubscriptionTieredWithMinimumPrice.currency - externalPriceId = newSubscriptionTieredWithMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTieredWithMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTieredWithMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionTieredWithMinimumPrice.invoicingCycleConfiguration - metadata = newSubscriptionTieredWithMinimumPrice.metadata - referenceId = newSubscriptionTieredWithMinimumPrice.referenceId - additionalProperties = - newSubscriptionTieredWithMinimumPrice.additionalProperties - .toMutableMap() + internal fun from(tieredWithMinimum: TieredWithMinimum) = apply { + cadence = tieredWithMinimum.cadence + itemId = tieredWithMinimum.itemId + modelType = tieredWithMinimum.modelType + name = tieredWithMinimum.name + tieredWithMinimumConfig = tieredWithMinimum.tieredWithMinimumConfig + billableMetricId = tieredWithMinimum.billableMetricId + billedInAdvance = tieredWithMinimum.billedInAdvance + billingCycleConfiguration = tieredWithMinimum.billingCycleConfiguration + conversionRate = tieredWithMinimum.conversionRate + currency = tieredWithMinimum.currency + externalPriceId = tieredWithMinimum.externalPriceId + fixedPriceQuantity = tieredWithMinimum.fixedPriceQuantity + invoiceGroupingKey = tieredWithMinimum.invoiceGroupingKey + invoicingCycleConfiguration = tieredWithMinimum.invoicingCycleConfiguration + metadata = tieredWithMinimum.metadata + referenceId = tieredWithMinimum.referenceId + additionalProperties = tieredWithMinimum.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -97872,18 +90641,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("tiered_with_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -98218,7 +90988,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTieredWithMinimumPrice]. + * Returns an immutable instance of [TieredWithMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -98226,18 +90996,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithMinimumConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTieredWithMinimumPrice = - NewSubscriptionTieredWithMinimumPrice( + fun build(): TieredWithMinimum = + TieredWithMinimum( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithMinimumConfig", tieredWithMinimumConfig), billableMetricId, @@ -98257,14 +91026,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { + fun validate(): TieredWithMinimum = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithMinimumConfig().validate() billableMetricId() @@ -98299,7 +91072,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("tiered_with_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (tieredWithMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -98473,135 +91248,6 @@ private constructor( 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_MINIMUM = of("tiered_with_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - TIERED_WITH_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TIERED_WITH_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TIERED_WITH_MINIMUM -> Value.TIERED_WITH_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TIERED_WITH_MINIMUM -> Known.TIERED_WITH_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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 TieredWithMinimumConfig @JsonCreator private constructor( @@ -99554,7 +92200,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is TieredWithMinimum && 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 && currency == other.currency && 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 */ @@ -99564,14 +92210,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionTieredWithMinimumPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithMinimum{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionUnitWithPercentPrice + class UnitWithPercent private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithPercentConfig: JsonField, private val billableMetricId: JsonField, @@ -99598,7 +92244,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -99679,11 +92325,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -99825,16 +92475,6 @@ private constructor( */ @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]. * @@ -99981,14 +92621,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitWithPercentPrice]. + * Returns a mutable builder for constructing an instance of [UnitWithPercent]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` @@ -99996,12 +92634,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitWithPercentPrice]. */ + /** A builder for [UnitWithPercent]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_percent") private var name: JsonField? = null private var unitWithPercentConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -100021,30 +92659,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionUnitWithPercentPrice: NewSubscriptionUnitWithPercentPrice - ) = apply { - cadence = newSubscriptionUnitWithPercentPrice.cadence - itemId = newSubscriptionUnitWithPercentPrice.itemId - modelType = newSubscriptionUnitWithPercentPrice.modelType - name = newSubscriptionUnitWithPercentPrice.name - unitWithPercentConfig = - newSubscriptionUnitWithPercentPrice.unitWithPercentConfig - billableMetricId = newSubscriptionUnitWithPercentPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithPercentPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithPercentPrice.conversionRate - currency = newSubscriptionUnitWithPercentPrice.currency - externalPriceId = newSubscriptionUnitWithPercentPrice.externalPriceId - fixedPriceQuantity = newSubscriptionUnitWithPercentPrice.fixedPriceQuantity - invoiceGroupingKey = newSubscriptionUnitWithPercentPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithPercentPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithPercentPrice.metadata - referenceId = newSubscriptionUnitWithPercentPrice.referenceId - additionalProperties = - newSubscriptionUnitWithPercentPrice.additionalProperties.toMutableMap() + internal fun from(unitWithPercent: UnitWithPercent) = apply { + cadence = unitWithPercent.cadence + itemId = unitWithPercent.itemId + modelType = unitWithPercent.modelType + name = unitWithPercent.name + unitWithPercentConfig = unitWithPercent.unitWithPercentConfig + billableMetricId = unitWithPercent.billableMetricId + billedInAdvance = unitWithPercent.billedInAdvance + billingCycleConfiguration = unitWithPercent.billingCycleConfiguration + conversionRate = unitWithPercent.conversionRate + currency = unitWithPercent.currency + externalPriceId = unitWithPercent.externalPriceId + fixedPriceQuantity = unitWithPercent.fixedPriceQuantity + invoiceGroupingKey = unitWithPercent.invoiceGroupingKey + invoicingCycleConfiguration = unitWithPercent.invoicingCycleConfiguration + metadata = unitWithPercent.metadata + referenceId = unitWithPercent.referenceId + additionalProperties = unitWithPercent.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -100071,18 +92703,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_percent") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -100417,7 +93050,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitWithPercentPrice]. + * Returns an immutable instance of [UnitWithPercent]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -100425,18 +93058,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithPercentConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitWithPercentPrice = - NewSubscriptionUnitWithPercentPrice( + fun build(): UnitWithPercent = + UnitWithPercent( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithPercentConfig", unitWithPercentConfig), billableMetricId, @@ -100456,14 +93088,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitWithPercentPrice = apply { + fun validate(): UnitWithPercent = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_percent")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithPercentConfig().validate() billableMetricId() @@ -100498,7 +93134,7 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("unit_with_percent")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithPercentConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -100672,135 +93308,6 @@ private constructor( 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 UNIT_WITH_PERCENT = of("unit_with_percent") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_WITH_PERCENT - } - - /** - * 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 { - UNIT_WITH_PERCENT, - /** - * 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) { - UNIT_WITH_PERCENT -> Value.UNIT_WITH_PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UNIT_WITH_PERCENT -> Known.UNIT_WITH_PERCENT - 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 UnitWithPercentConfig @JsonCreator private constructor( @@ -101752,7 +94259,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithPercent && 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 && currency == other.currency && 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 */ @@ -101762,14 +94269,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithPercentPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "UnitWithPercent{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionPackageWithAllocationPrice + class PackageWithAllocation private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val packageWithAllocationConfig: JsonField, private val billableMetricId: JsonField, @@ -101796,7 +94303,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -101878,11 +94385,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -102024,16 +94535,6 @@ private constructor( */ @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]. * @@ -102181,13 +94682,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionPackageWithAllocationPrice]. + * [PackageWithAllocation]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` @@ -102195,12 +94695,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionPackageWithAllocationPrice]. */ + /** A builder for [PackageWithAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("package_with_allocation") private var name: JsonField? = null private var packageWithAllocationConfig: JsonField? = @@ -102222,35 +94722,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionPackageWithAllocationPrice: - NewSubscriptionPackageWithAllocationPrice - ) = apply { - cadence = newSubscriptionPackageWithAllocationPrice.cadence - itemId = newSubscriptionPackageWithAllocationPrice.itemId - modelType = newSubscriptionPackageWithAllocationPrice.modelType - name = newSubscriptionPackageWithAllocationPrice.name + internal fun from(packageWithAllocation: PackageWithAllocation) = apply { + cadence = packageWithAllocation.cadence + itemId = packageWithAllocation.itemId + modelType = packageWithAllocation.modelType + name = packageWithAllocation.name packageWithAllocationConfig = - newSubscriptionPackageWithAllocationPrice.packageWithAllocationConfig - billableMetricId = - newSubscriptionPackageWithAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionPackageWithAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionPackageWithAllocationPrice.conversionRate - currency = newSubscriptionPackageWithAllocationPrice.currency - externalPriceId = newSubscriptionPackageWithAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionPackageWithAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionPackageWithAllocationPrice.invoiceGroupingKey + packageWithAllocation.packageWithAllocationConfig + billableMetricId = packageWithAllocation.billableMetricId + billedInAdvance = packageWithAllocation.billedInAdvance + billingCycleConfiguration = packageWithAllocation.billingCycleConfiguration + conversionRate = packageWithAllocation.conversionRate + currency = packageWithAllocation.currency + externalPriceId = packageWithAllocation.externalPriceId + fixedPriceQuantity = packageWithAllocation.fixedPriceQuantity + invoiceGroupingKey = packageWithAllocation.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionPackageWithAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionPackageWithAllocationPrice.metadata - referenceId = newSubscriptionPackageWithAllocationPrice.referenceId + packageWithAllocation.invoicingCycleConfiguration + metadata = packageWithAllocation.metadata + referenceId = packageWithAllocation.referenceId additionalProperties = - newSubscriptionPackageWithAllocationPrice.additionalProperties - .toMutableMap() + packageWithAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -102277,18 +94769,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("package_with_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -102625,7 +95118,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionPackageWithAllocationPrice]. + * Returns an immutable instance of [PackageWithAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -102633,18 +95126,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .packageWithAllocationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionPackageWithAllocationPrice = - NewSubscriptionPackageWithAllocationPrice( + fun build(): PackageWithAllocation = + PackageWithAllocation( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "packageWithAllocationConfig", @@ -102667,14 +95159,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { + fun validate(): PackageWithAllocation = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("package_with_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() packageWithAllocationConfig().validate() billableMetricId() @@ -102709,7 +95205,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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 (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -102883,135 +95381,6 @@ private constructor( 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 PACKAGE_WITH_ALLOCATION = of("package_with_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - PACKAGE_WITH_ALLOCATION - } - - /** - * 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 { - PACKAGE_WITH_ALLOCATION, - /** - * 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) { - PACKAGE_WITH_ALLOCATION -> Value.PACKAGE_WITH_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PACKAGE_WITH_ALLOCATION -> Known.PACKAGE_WITH_ALLOCATION - 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 PackageWithAllocationConfig @JsonCreator private constructor( @@ -103965,7 +96334,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PackageWithAllocation && 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 && currency == other.currency && 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 */ @@ -103975,14 +96344,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "PackageWithAllocation{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionTierWithProrationPrice + class TieredWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val tieredWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -104009,7 +96378,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -104091,11 +96460,15 @@ private constructor( 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). + * 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). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -104237,16 +96610,6 @@ private constructor( */ @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]. * @@ -104394,13 +96757,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionTierWithProrationPrice]. + * [TieredWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` @@ -104408,12 +96770,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionTierWithProrationPrice]. */ + /** A builder for [TieredWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("tiered_with_proration") private var name: JsonField? = null private var tieredWithProrationConfig: JsonField? = null @@ -104434,33 +96796,26 @@ private constructor( 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 - currency = newSubscriptionTierWithProrationPrice.currency - externalPriceId = newSubscriptionTierWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionTierWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionTierWithProrationPrice.invoiceGroupingKey + 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 + currency = tieredWithProration.currency + externalPriceId = tieredWithProration.externalPriceId + fixedPriceQuantity = tieredWithProration.fixedPriceQuantity + invoiceGroupingKey = tieredWithProration.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionTierWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionTierWithProrationPrice.metadata - referenceId = newSubscriptionTierWithProrationPrice.referenceId + tieredWithProration.invoicingCycleConfiguration + metadata = tieredWithProration.metadata + referenceId = tieredWithProration.referenceId additionalProperties = - newSubscriptionTierWithProrationPrice.additionalProperties - .toMutableMap() + tieredWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -104487,18 +96842,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * 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: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -104834,7 +97190,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionTierWithProrationPrice]. + * Returns an immutable instance of [TieredWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -104842,18 +97198,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .tieredWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionTierWithProrationPrice = - NewSubscriptionTierWithProrationPrice( + fun build(): TieredWithProration = + TieredWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("tieredWithProrationConfig", tieredWithProrationConfig), billableMetricId, @@ -104873,14 +97228,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionTierWithProrationPrice = apply { + fun validate(): TieredWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("tiered_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() tieredWithProrationConfig().validate() billableMetricId() @@ -104915,7 +97274,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 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) + @@ -105089,135 +97450,6 @@ private constructor( 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( @@ -106170,7 +98402,7 @@ private constructor( return true } - return /* spotless:off */ other is NewSubscriptionTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ 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 && currency == other.currency && 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 */ @@ -106180,14 +98412,14 @@ private constructor( 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, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "TieredWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionUnitWithProrationPrice + class UnitWithProration private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val unitWithProrationConfig: JsonField, private val billableMetricId: JsonField, @@ -106214,7 +98446,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -106295,11 +98527,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -106441,16 +98677,6 @@ private constructor( */ @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]. * @@ -106598,13 +98824,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionUnitWithProrationPrice]. + * [UnitWithProration]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` @@ -106612,12 +98837,12 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionUnitWithProrationPrice]. */ + /** A builder for [UnitWithProration]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("unit_with_proration") private var name: JsonField? = null private var unitWithProrationConfig: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() @@ -106637,33 +98862,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionUnitWithProrationPrice: NewSubscriptionUnitWithProrationPrice - ) = apply { - cadence = newSubscriptionUnitWithProrationPrice.cadence - itemId = newSubscriptionUnitWithProrationPrice.itemId - modelType = newSubscriptionUnitWithProrationPrice.modelType - name = newSubscriptionUnitWithProrationPrice.name - unitWithProrationConfig = - newSubscriptionUnitWithProrationPrice.unitWithProrationConfig - billableMetricId = newSubscriptionUnitWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionUnitWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionUnitWithProrationPrice.conversionRate - currency = newSubscriptionUnitWithProrationPrice.currency - externalPriceId = newSubscriptionUnitWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionUnitWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionUnitWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionUnitWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionUnitWithProrationPrice.metadata - referenceId = newSubscriptionUnitWithProrationPrice.referenceId - additionalProperties = - newSubscriptionUnitWithProrationPrice.additionalProperties - .toMutableMap() + internal fun from(unitWithProration: UnitWithProration) = apply { + cadence = unitWithProration.cadence + itemId = unitWithProration.itemId + modelType = unitWithProration.modelType + name = unitWithProration.name + unitWithProrationConfig = unitWithProration.unitWithProrationConfig + billableMetricId = unitWithProration.billableMetricId + billedInAdvance = unitWithProration.billedInAdvance + billingCycleConfiguration = unitWithProration.billingCycleConfiguration + conversionRate = unitWithProration.conversionRate + currency = unitWithProration.currency + externalPriceId = unitWithProration.externalPriceId + fixedPriceQuantity = unitWithProration.fixedPriceQuantity + invoiceGroupingKey = unitWithProration.invoiceGroupingKey + invoicingCycleConfiguration = unitWithProration.invoicingCycleConfiguration + metadata = unitWithProration.metadata + referenceId = unitWithProration.referenceId + additionalProperties = unitWithProration.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -106690,18 +98906,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("unit_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -107036,7 +99253,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionUnitWithProrationPrice]. + * Returns an immutable instance of [UnitWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -107044,18 +99261,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .unitWithProrationConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionUnitWithProrationPrice = - NewSubscriptionUnitWithProrationPrice( + fun build(): UnitWithProration = + UnitWithProration( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired("unitWithProrationConfig", unitWithProrationConfig), billableMetricId, @@ -107075,14 +99291,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionUnitWithProrationPrice = apply { + fun validate(): UnitWithProration = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("unit_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() unitWithProrationConfig().validate() billableMetricId() @@ -107117,7 +99337,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("unit_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (unitWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + @@ -107291,135 +99513,6 @@ private constructor( 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 UNIT_WITH_PRORATION = of("unit_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - UNIT_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 { - UNIT_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) { - UNIT_WITH_PRORATION -> Value.UNIT_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) { - UNIT_WITH_PRORATION -> Known.UNIT_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 UnitWithProrationConfig @JsonCreator private constructor( @@ -108372,7 +100465,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnitWithProration && 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 && currency == other.currency && 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 */ @@ -108382,15 +100475,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "UnitWithProration{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedAllocationPrice + class GroupedAllocation private constructor( private val cadence: JsonField, private val groupedAllocationConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -108419,7 +100512,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -108505,11 +100598,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -108654,16 +100751,6 @@ private constructor( */ @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]. * @@ -108800,27 +100887,26 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedAllocationPrice]. + * [GroupedAllocation]. * * The following fields are required: * ```java * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedAllocationPrice]. */ + /** A builder for [GroupedAllocation]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedAllocationConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_allocation") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -108839,33 +100925,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedAllocationPrice: NewSubscriptionGroupedAllocationPrice - ) = apply { - cadence = newSubscriptionGroupedAllocationPrice.cadence - groupedAllocationConfig = - newSubscriptionGroupedAllocationPrice.groupedAllocationConfig - itemId = newSubscriptionGroupedAllocationPrice.itemId - modelType = newSubscriptionGroupedAllocationPrice.modelType - name = newSubscriptionGroupedAllocationPrice.name - billableMetricId = newSubscriptionGroupedAllocationPrice.billableMetricId - billedInAdvance = newSubscriptionGroupedAllocationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedAllocationPrice.conversionRate - currency = newSubscriptionGroupedAllocationPrice.currency - externalPriceId = newSubscriptionGroupedAllocationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedAllocationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedAllocationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedAllocationPrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedAllocationPrice.metadata - referenceId = newSubscriptionGroupedAllocationPrice.referenceId - additionalProperties = - newSubscriptionGroupedAllocationPrice.additionalProperties - .toMutableMap() + internal fun from(groupedAllocation: GroupedAllocation) = apply { + cadence = groupedAllocation.cadence + groupedAllocationConfig = groupedAllocation.groupedAllocationConfig + itemId = groupedAllocation.itemId + modelType = groupedAllocation.modelType + name = groupedAllocation.name + billableMetricId = groupedAllocation.billableMetricId + billedInAdvance = groupedAllocation.billedInAdvance + billingCycleConfiguration = groupedAllocation.billingCycleConfiguration + conversionRate = groupedAllocation.conversionRate + currency = groupedAllocation.currency + externalPriceId = groupedAllocation.externalPriceId + fixedPriceQuantity = groupedAllocation.fixedPriceQuantity + invoiceGroupingKey = groupedAllocation.invoiceGroupingKey + invoicingCycleConfiguration = groupedAllocation.invoicingCycleConfiguration + metadata = groupedAllocation.metadata + referenceId = groupedAllocation.referenceId + additionalProperties = groupedAllocation.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -108906,18 +100983,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_allocation") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -109238,7 +101316,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionGroupedAllocationPrice]. + * Returns an immutable instance of [GroupedAllocation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -109247,18 +101325,17 @@ private constructor( * .cadence() * .groupedAllocationConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedAllocationPrice = - NewSubscriptionGroupedAllocationPrice( + fun build(): GroupedAllocation = + GroupedAllocation( checkRequired("cadence", cadence), checkRequired("groupedAllocationConfig", groupedAllocationConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -109277,7 +101354,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedAllocationPrice = apply { + fun validate(): GroupedAllocation = apply { if (validated) { return@apply } @@ -109285,7 +101362,11 @@ private constructor( cadence().validate() groupedAllocationConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_allocation")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -109320,7 +101401,7 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedAllocationConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { if (it == JsonValue.from("grouped_allocation")) 1 else 0 } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -109607,135 +101688,6 @@ private constructor( "GroupedAllocationConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_ALLOCATION = of("grouped_allocation") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_ALLOCATION - } - - /** - * 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 { - GROUPED_ALLOCATION, - /** - * 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) { - GROUPED_ALLOCATION -> Value.GROUPED_ALLOCATION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_ALLOCATION -> Known.GROUPED_ALLOCATION - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -110574,7 +102526,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedAllocation && 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 && currency == other.currency && 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 */ @@ -110584,16 +102536,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedAllocation{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedWithProratedMinimumPrice + class GroupedWithProratedMinimum private constructor( private val cadence: JsonField, private val groupedWithProratedMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -110623,7 +102575,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -110711,11 +102663,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -110860,16 +102816,6 @@ private constructor( */ @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]. * @@ -111006,21 +102952,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedWithProratedMinimumPrice]. + * [GroupedWithProratedMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedWithProratedMinimumPrice]. */ + /** A builder for [GroupedWithProratedMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -111028,7 +102973,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_prorated_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -111047,41 +102993,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithProratedMinimumPrice: - NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithProratedMinimumPrice.cadence - groupedWithProratedMinimumConfig = - newSubscriptionGroupedWithProratedMinimumPrice - .groupedWithProratedMinimumConfig - itemId = newSubscriptionGroupedWithProratedMinimumPrice.itemId - modelType = newSubscriptionGroupedWithProratedMinimumPrice.modelType - name = newSubscriptionGroupedWithProratedMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithProratedMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithProratedMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithProratedMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithProratedMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithProratedMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithProratedMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithProratedMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithProratedMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithProratedMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithProratedMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithProratedMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithProratedMinimum: GroupedWithProratedMinimum) = + apply { + cadence = groupedWithProratedMinimum.cadence + groupedWithProratedMinimumConfig = + groupedWithProratedMinimum.groupedWithProratedMinimumConfig + itemId = groupedWithProratedMinimum.itemId + modelType = groupedWithProratedMinimum.modelType + name = groupedWithProratedMinimum.name + billableMetricId = groupedWithProratedMinimum.billableMetricId + billedInAdvance = groupedWithProratedMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithProratedMinimum.billingCycleConfiguration + conversionRate = groupedWithProratedMinimum.conversionRate + currency = groupedWithProratedMinimum.currency + externalPriceId = groupedWithProratedMinimum.externalPriceId + fixedPriceQuantity = groupedWithProratedMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithProratedMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithProratedMinimum.invoicingCycleConfiguration + metadata = groupedWithProratedMinimum.metadata + referenceId = groupedWithProratedMinimum.referenceId + additionalProperties = + groupedWithProratedMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -111129,18 +103064,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_prorated_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -111461,8 +103397,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionGroupedWithProratedMinimumPrice]. + * Returns an immutable instance of [GroupedWithProratedMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -111471,21 +103406,20 @@ private constructor( * .cadence() * .groupedWithProratedMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedWithProratedMinimumPrice = - NewSubscriptionGroupedWithProratedMinimumPrice( + fun build(): GroupedWithProratedMinimum = + GroupedWithProratedMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithProratedMinimumConfig", groupedWithProratedMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -111504,7 +103438,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { + fun validate(): GroupedWithProratedMinimum = apply { if (validated) { return@apply } @@ -111512,7 +103446,11 @@ private constructor( cadence().validate() groupedWithProratedMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_prorated_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -111547,7 +103485,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithProratedMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_prorated_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -111835,136 +103775,6 @@ private constructor( "GroupedWithProratedMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_PRORATED_MINIMUM = of("grouped_with_prorated_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_PRORATED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_PRORATED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Value.GROUPED_WITH_PRORATED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_PRORATED_MINIMUM -> Known.GROUPED_WITH_PRORATED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -112803,7 +104613,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithProratedMinimum && 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 && currency == other.currency && 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 */ @@ -112813,15 +104623,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithProratedMinimumPrice{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithProratedMinimum{cadence=$cadence, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionBulkWithProrationPrice + class BulkWithProration private constructor( private val bulkWithProrationConfig: JsonField, private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -112850,7 +104660,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -112936,11 +104746,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -113085,16 +104899,6 @@ private constructor( */ @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]. * @@ -113231,27 +105035,26 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionBulkWithProrationPrice]. + * [BulkWithProration]. * * The following fields are required: * ```java * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionBulkWithProrationPrice]. */ + /** A builder for [BulkWithProration]. */ class Builder internal constructor() { private var bulkWithProrationConfig: JsonField? = null private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("bulk_with_proration") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -113270,33 +105073,24 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionBulkWithProrationPrice: NewSubscriptionBulkWithProrationPrice - ) = apply { - bulkWithProrationConfig = - newSubscriptionBulkWithProrationPrice.bulkWithProrationConfig - cadence = newSubscriptionBulkWithProrationPrice.cadence - itemId = newSubscriptionBulkWithProrationPrice.itemId - modelType = newSubscriptionBulkWithProrationPrice.modelType - name = newSubscriptionBulkWithProrationPrice.name - billableMetricId = newSubscriptionBulkWithProrationPrice.billableMetricId - billedInAdvance = newSubscriptionBulkWithProrationPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.billingCycleConfiguration - conversionRate = newSubscriptionBulkWithProrationPrice.conversionRate - currency = newSubscriptionBulkWithProrationPrice.currency - externalPriceId = newSubscriptionBulkWithProrationPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionBulkWithProrationPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionBulkWithProrationPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionBulkWithProrationPrice.invoicingCycleConfiguration - metadata = newSubscriptionBulkWithProrationPrice.metadata - referenceId = newSubscriptionBulkWithProrationPrice.referenceId - additionalProperties = - newSubscriptionBulkWithProrationPrice.additionalProperties - .toMutableMap() + internal fun from(bulkWithProration: BulkWithProration) = apply { + bulkWithProrationConfig = bulkWithProration.bulkWithProrationConfig + cadence = bulkWithProration.cadence + itemId = bulkWithProration.itemId + modelType = bulkWithProration.modelType + name = bulkWithProration.name + billableMetricId = bulkWithProration.billableMetricId + billedInAdvance = bulkWithProration.billedInAdvance + billingCycleConfiguration = bulkWithProration.billingCycleConfiguration + conversionRate = bulkWithProration.conversionRate + currency = bulkWithProration.currency + externalPriceId = bulkWithProration.externalPriceId + fixedPriceQuantity = bulkWithProration.fixedPriceQuantity + invoiceGroupingKey = bulkWithProration.invoiceGroupingKey + invoicingCycleConfiguration = bulkWithProration.invoicingCycleConfiguration + metadata = bulkWithProration.metadata + referenceId = bulkWithProration.referenceId + additionalProperties = bulkWithProration.additionalProperties.toMutableMap() } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = @@ -113337,18 +105131,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("bulk_with_proration") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -113669,7 +105464,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionBulkWithProrationPrice]. + * Returns an immutable instance of [BulkWithProration]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -113678,18 +105473,17 @@ private constructor( * .bulkWithProrationConfig() * .cadence() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionBulkWithProrationPrice = - NewSubscriptionBulkWithProrationPrice( + fun build(): BulkWithProration = + BulkWithProration( checkRequired("bulkWithProrationConfig", bulkWithProrationConfig), checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -113708,7 +105502,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionBulkWithProrationPrice = apply { + fun validate(): BulkWithProration = apply { if (validated) { return@apply } @@ -113716,7 +105510,11 @@ private constructor( bulkWithProrationConfig().validate() cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("bulk_with_proration")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -113751,7 +105549,9 @@ private constructor( (bulkWithProrationConfig.asKnown().getOrNull()?.validity() ?: 0) + (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("bulk_with_proration")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -114038,135 +105838,6 @@ private constructor( 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 BULK_WITH_PRORATION = of("bulk_with_proration") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - BULK_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 { - BULK_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) { - BULK_WITH_PRORATION -> Value.BULK_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) { - BULK_WITH_PRORATION -> Known.BULK_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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -115005,7 +106676,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is BulkWithProration && 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 && currency == other.currency && 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 */ @@ -115015,14 +106686,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionBulkWithProrationPrice{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "BulkWithProration{bulkWithProrationConfig=$bulkWithProrationConfig, cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionScalableMatrixWithUnitPricingPrice + class ScalableMatrixWithUnitPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithUnitPricingConfig: JsonField, @@ -115050,7 +106721,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -115133,11 +106804,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -115281,16 +106956,6 @@ private constructor( */ @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]. * @@ -115439,13 +107104,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionScalableMatrixWithUnitPricingPrice]. + * [ScalableMatrixWithUnitPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` @@ -115453,12 +107117,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionScalableMatrixWithUnitPricingPrice]. */ + /** A builder for [ScalableMatrixWithUnitPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_unit_pricing") private var name: JsonField? = null private var scalableMatrixWithUnitPricingConfig: JsonField? = @@ -115481,40 +107146,29 @@ private constructor( @JvmSynthetic internal fun from( - newSubscriptionScalableMatrixWithUnitPricingPrice: - NewSubscriptionScalableMatrixWithUnitPricingPrice + scalableMatrixWithUnitPricing: ScalableMatrixWithUnitPricing ) = apply { - cadence = newSubscriptionScalableMatrixWithUnitPricingPrice.cadence - itemId = newSubscriptionScalableMatrixWithUnitPricingPrice.itemId - modelType = newSubscriptionScalableMatrixWithUnitPricingPrice.modelType - name = newSubscriptionScalableMatrixWithUnitPricingPrice.name + cadence = scalableMatrixWithUnitPricing.cadence + itemId = scalableMatrixWithUnitPricing.itemId + modelType = scalableMatrixWithUnitPricing.modelType + name = scalableMatrixWithUnitPricing.name scalableMatrixWithUnitPricingConfig = - newSubscriptionScalableMatrixWithUnitPricingPrice - .scalableMatrixWithUnitPricingConfig - billableMetricId = - newSubscriptionScalableMatrixWithUnitPricingPrice.billableMetricId - billedInAdvance = - newSubscriptionScalableMatrixWithUnitPricingPrice.billedInAdvance + scalableMatrixWithUnitPricing.scalableMatrixWithUnitPricingConfig + billableMetricId = scalableMatrixWithUnitPricing.billableMetricId + billedInAdvance = scalableMatrixWithUnitPricing.billedInAdvance billingCycleConfiguration = - newSubscriptionScalableMatrixWithUnitPricingPrice - .billingCycleConfiguration - conversionRate = - newSubscriptionScalableMatrixWithUnitPricingPrice.conversionRate - currency = newSubscriptionScalableMatrixWithUnitPricingPrice.currency - externalPriceId = - newSubscriptionScalableMatrixWithUnitPricingPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionScalableMatrixWithUnitPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionScalableMatrixWithUnitPricingPrice.invoiceGroupingKey + scalableMatrixWithUnitPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithUnitPricing.conversionRate + currency = scalableMatrixWithUnitPricing.currency + externalPriceId = scalableMatrixWithUnitPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithUnitPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithUnitPricing.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionScalableMatrixWithUnitPricingPrice - .invoicingCycleConfiguration - metadata = newSubscriptionScalableMatrixWithUnitPricingPrice.metadata - referenceId = newSubscriptionScalableMatrixWithUnitPricingPrice.referenceId + scalableMatrixWithUnitPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithUnitPricing.metadata + referenceId = scalableMatrixWithUnitPricing.referenceId additionalProperties = - newSubscriptionScalableMatrixWithUnitPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithUnitPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -115541,18 +107195,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_unit_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -115897,8 +107552,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionScalableMatrixWithUnitPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithUnitPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -115906,18 +107560,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithUnitPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionScalableMatrixWithUnitPricingPrice = - NewSubscriptionScalableMatrixWithUnitPricingPrice( + fun build(): ScalableMatrixWithUnitPricing = + ScalableMatrixWithUnitPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithUnitPricingConfig", @@ -115940,14 +107593,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionScalableMatrixWithUnitPricingPrice = apply { + fun validate(): ScalableMatrixWithUnitPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_unit_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithUnitPricingConfig().validate() billableMetricId() @@ -115982,7 +107639,9 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_unit_pricing")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithUnitPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -116157,139 +107816,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_UNIT_PRICING = - of("scalable_matrix_with_unit_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_UNIT_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_UNIT_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Value.SCALABLE_MATRIX_WITH_UNIT_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_UNIT_PRICING -> - Known.SCALABLE_MATRIX_WITH_UNIT_PRICING - 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 ScalableMatrixWithUnitPricingConfig @JsonCreator private constructor( @@ -117244,7 +108770,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithUnitPricing && 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 && currency == other.currency && 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 */ @@ -117254,14 +108780,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithUnitPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ScalableMatrixWithUnitPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithUnitPricingConfig=$scalableMatrixWithUnitPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionScalableMatrixWithTieredPricingPrice + class ScalableMatrixWithTieredPricing private constructor( private val cadence: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val scalableMatrixWithTieredPricingConfig: JsonField, @@ -117289,7 +108815,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -117372,11 +108898,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -117520,16 +109050,6 @@ private constructor( */ @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]. * @@ -117678,13 +109198,12 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionScalableMatrixWithTieredPricingPrice]. + * [ScalableMatrixWithTieredPricing]. * * The following fields are required: * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` @@ -117692,12 +109211,13 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionScalableMatrixWithTieredPricingPrice]. */ + /** A builder for [ScalableMatrixWithTieredPricing]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("scalable_matrix_with_tiered_pricing") private var name: JsonField? = null private var scalableMatrixWithTieredPricingConfig: JsonField? = @@ -117720,41 +109240,29 @@ private constructor( @JvmSynthetic internal fun from( - newSubscriptionScalableMatrixWithTieredPricingPrice: - NewSubscriptionScalableMatrixWithTieredPricingPrice + scalableMatrixWithTieredPricing: ScalableMatrixWithTieredPricing ) = apply { - cadence = newSubscriptionScalableMatrixWithTieredPricingPrice.cadence - itemId = newSubscriptionScalableMatrixWithTieredPricingPrice.itemId - modelType = newSubscriptionScalableMatrixWithTieredPricingPrice.modelType - name = newSubscriptionScalableMatrixWithTieredPricingPrice.name + cadence = scalableMatrixWithTieredPricing.cadence + itemId = scalableMatrixWithTieredPricing.itemId + modelType = scalableMatrixWithTieredPricing.modelType + name = scalableMatrixWithTieredPricing.name scalableMatrixWithTieredPricingConfig = - newSubscriptionScalableMatrixWithTieredPricingPrice - .scalableMatrixWithTieredPricingConfig - billableMetricId = - newSubscriptionScalableMatrixWithTieredPricingPrice.billableMetricId - billedInAdvance = - newSubscriptionScalableMatrixWithTieredPricingPrice.billedInAdvance + scalableMatrixWithTieredPricing.scalableMatrixWithTieredPricingConfig + billableMetricId = scalableMatrixWithTieredPricing.billableMetricId + billedInAdvance = scalableMatrixWithTieredPricing.billedInAdvance billingCycleConfiguration = - newSubscriptionScalableMatrixWithTieredPricingPrice - .billingCycleConfiguration - conversionRate = - newSubscriptionScalableMatrixWithTieredPricingPrice.conversionRate - currency = newSubscriptionScalableMatrixWithTieredPricingPrice.currency - externalPriceId = - newSubscriptionScalableMatrixWithTieredPricingPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionScalableMatrixWithTieredPricingPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionScalableMatrixWithTieredPricingPrice.invoiceGroupingKey + scalableMatrixWithTieredPricing.billingCycleConfiguration + conversionRate = scalableMatrixWithTieredPricing.conversionRate + currency = scalableMatrixWithTieredPricing.currency + externalPriceId = scalableMatrixWithTieredPricing.externalPriceId + fixedPriceQuantity = scalableMatrixWithTieredPricing.fixedPriceQuantity + invoiceGroupingKey = scalableMatrixWithTieredPricing.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionScalableMatrixWithTieredPricingPrice - .invoicingCycleConfiguration - metadata = newSubscriptionScalableMatrixWithTieredPricingPrice.metadata - referenceId = - newSubscriptionScalableMatrixWithTieredPricingPrice.referenceId + scalableMatrixWithTieredPricing.invoicingCycleConfiguration + metadata = scalableMatrixWithTieredPricing.metadata + referenceId = scalableMatrixWithTieredPricing.referenceId additionalProperties = - newSubscriptionScalableMatrixWithTieredPricingPrice.additionalProperties - .toMutableMap() + scalableMatrixWithTieredPricing.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -117781,18 +109289,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("scalable_matrix_with_tiered_pricing") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -118137,8 +109646,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionScalableMatrixWithTieredPricingPrice]. + * Returns an immutable instance of [ScalableMatrixWithTieredPricing]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -118146,18 +109654,17 @@ private constructor( * ```java * .cadence() * .itemId() - * .modelType() * .name() * .scalableMatrixWithTieredPricingConfig() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionScalableMatrixWithTieredPricingPrice = - NewSubscriptionScalableMatrixWithTieredPricingPrice( + fun build(): ScalableMatrixWithTieredPricing = + ScalableMatrixWithTieredPricing( checkRequired("cadence", cadence), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), checkRequired( "scalableMatrixWithTieredPricingConfig", @@ -118180,14 +109687,18 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionScalableMatrixWithTieredPricingPrice = apply { + fun validate(): ScalableMatrixWithTieredPricing = apply { if (validated) { return@apply } cadence().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("scalable_matrix_with_tiered_pricing")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() scalableMatrixWithTieredPricingConfig().validate() billableMetricId() @@ -118222,7 +109733,10 @@ private constructor( internal fun validity(): Int = (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("scalable_matrix_with_tiered_pricing")) 1 + else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (scalableMatrixWithTieredPricingConfig.asKnown().getOrNull()?.validity() ?: 0) + @@ -118397,139 +109911,6 @@ private constructor( 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 SCALABLE_MATRIX_WITH_TIERED_PRICING = - of("scalable_matrix_with_tiered_pricing") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - SCALABLE_MATRIX_WITH_TIERED_PRICING - } - - /** - * 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 { - SCALABLE_MATRIX_WITH_TIERED_PRICING, - /** - * 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) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Value.SCALABLE_MATRIX_WITH_TIERED_PRICING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SCALABLE_MATRIX_WITH_TIERED_PRICING -> - Known.SCALABLE_MATRIX_WITH_TIERED_PRICING - 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 ScalableMatrixWithTieredPricingConfig @JsonCreator private constructor( @@ -119487,7 +110868,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is ScalableMatrixWithTieredPricing && 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 && currency == other.currency && 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 */ @@ -119497,15 +110878,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionScalableMatrixWithTieredPricingPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "ScalableMatrixWithTieredPricing{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, scalableMatrixWithTieredPricingConfig=$scalableMatrixWithTieredPricingConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionCumulativeGroupedBulkPrice + class CumulativeGroupedBulk private constructor( private val cadence: JsonField, private val cumulativeGroupedBulkConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -119535,7 +110916,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -119621,11 +111002,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -119770,16 +111155,6 @@ private constructor( */ @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]. * @@ -119916,21 +111291,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionCumulativeGroupedBulkPrice]. + * [CumulativeGroupedBulk]. * * The following fields are required: * ```java * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionCumulativeGroupedBulkPrice]. */ + /** A builder for [CumulativeGroupedBulk]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -119938,7 +111312,7 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("cumulative_grouped_bulk") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -119957,35 +111331,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionCumulativeGroupedBulkPrice: - NewSubscriptionCumulativeGroupedBulkPrice - ) = apply { - cadence = newSubscriptionCumulativeGroupedBulkPrice.cadence + internal fun from(cumulativeGroupedBulk: CumulativeGroupedBulk) = apply { + cadence = cumulativeGroupedBulk.cadence cumulativeGroupedBulkConfig = - newSubscriptionCumulativeGroupedBulkPrice.cumulativeGroupedBulkConfig - itemId = newSubscriptionCumulativeGroupedBulkPrice.itemId - modelType = newSubscriptionCumulativeGroupedBulkPrice.modelType - name = newSubscriptionCumulativeGroupedBulkPrice.name - billableMetricId = - newSubscriptionCumulativeGroupedBulkPrice.billableMetricId - billedInAdvance = newSubscriptionCumulativeGroupedBulkPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionCumulativeGroupedBulkPrice.billingCycleConfiguration - conversionRate = newSubscriptionCumulativeGroupedBulkPrice.conversionRate - currency = newSubscriptionCumulativeGroupedBulkPrice.currency - externalPriceId = newSubscriptionCumulativeGroupedBulkPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionCumulativeGroupedBulkPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionCumulativeGroupedBulkPrice.invoiceGroupingKey + cumulativeGroupedBulk.cumulativeGroupedBulkConfig + itemId = cumulativeGroupedBulk.itemId + modelType = cumulativeGroupedBulk.modelType + name = cumulativeGroupedBulk.name + billableMetricId = cumulativeGroupedBulk.billableMetricId + billedInAdvance = cumulativeGroupedBulk.billedInAdvance + billingCycleConfiguration = cumulativeGroupedBulk.billingCycleConfiguration + conversionRate = cumulativeGroupedBulk.conversionRate + currency = cumulativeGroupedBulk.currency + externalPriceId = cumulativeGroupedBulk.externalPriceId + fixedPriceQuantity = cumulativeGroupedBulk.fixedPriceQuantity + invoiceGroupingKey = cumulativeGroupedBulk.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionCumulativeGroupedBulkPrice.invoicingCycleConfiguration - metadata = newSubscriptionCumulativeGroupedBulkPrice.metadata - referenceId = newSubscriptionCumulativeGroupedBulkPrice.referenceId + cumulativeGroupedBulk.invoicingCycleConfiguration + metadata = cumulativeGroupedBulk.metadata + referenceId = cumulativeGroupedBulk.referenceId additionalProperties = - newSubscriptionCumulativeGroupedBulkPrice.additionalProperties - .toMutableMap() + cumulativeGroupedBulk.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -120028,18 +111394,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("cumulative_grouped_bulk") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -120360,7 +111727,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionCumulativeGroupedBulkPrice]. + * Returns an immutable instance of [CumulativeGroupedBulk]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -120369,21 +111736,20 @@ private constructor( * .cadence() * .cumulativeGroupedBulkConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionCumulativeGroupedBulkPrice = - NewSubscriptionCumulativeGroupedBulkPrice( + fun build(): CumulativeGroupedBulk = + CumulativeGroupedBulk( checkRequired("cadence", cadence), checkRequired( "cumulativeGroupedBulkConfig", cumulativeGroupedBulkConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -120402,7 +111768,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionCumulativeGroupedBulkPrice = apply { + fun validate(): CumulativeGroupedBulk = apply { if (validated) { return@apply } @@ -120410,7 +111776,11 @@ private constructor( cadence().validate() cumulativeGroupedBulkConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("cumulative_grouped_bulk")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -120445,7 +111815,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (cumulativeGroupedBulkConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("cumulative_grouped_bulk")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -120733,135 +112105,6 @@ private constructor( "CumulativeGroupedBulkConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val CUMULATIVE_GROUPED_BULK = of("cumulative_grouped_bulk") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - CUMULATIVE_GROUPED_BULK - } - - /** - * 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 { - CUMULATIVE_GROUPED_BULK, - /** - * 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) { - CUMULATIVE_GROUPED_BULK -> Value.CUMULATIVE_GROUPED_BULK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CUMULATIVE_GROUPED_BULK -> Known.CUMULATIVE_GROUPED_BULK - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -121700,7 +112943,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CumulativeGroupedBulk && 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 && currency == other.currency && 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 */ @@ -121710,15 +112953,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionCumulativeGroupedBulkPrice{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "CumulativeGroupedBulk{cadence=$cadence, cumulativeGroupedBulkConfig=$cumulativeGroupedBulkConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMaxGroupTieredPackagePrice + class MaxGroupTieredPackage private constructor( private val cadence: JsonField, private val itemId: JsonField, private val maxGroupTieredPackageConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -121748,7 +112991,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -121834,11 +113077,15 @@ private constructor( maxGroupTieredPackageConfig.getRequired("max_group_tiered_package_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). + * Expected to always return the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -121983,16 +113230,6 @@ private constructor( fun _maxGroupTieredPackageConfig(): JsonField = maxGroupTieredPackageConfig - /** - * 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]. * @@ -122129,21 +113366,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMaxGroupTieredPackagePrice]. + * [MaxGroupTieredPackage]. * * The following fields are required: * ```java * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMaxGroupTieredPackagePrice]. */ + /** A builder for [MaxGroupTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -122151,7 +113387,7 @@ private constructor( private var maxGroupTieredPackageConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("max_group_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -122170,35 +113406,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionMaxGroupTieredPackagePrice: - NewSubscriptionMaxGroupTieredPackagePrice - ) = apply { - cadence = newSubscriptionMaxGroupTieredPackagePrice.cadence - itemId = newSubscriptionMaxGroupTieredPackagePrice.itemId + internal fun from(maxGroupTieredPackage: MaxGroupTieredPackage) = apply { + cadence = maxGroupTieredPackage.cadence + itemId = maxGroupTieredPackage.itemId maxGroupTieredPackageConfig = - newSubscriptionMaxGroupTieredPackagePrice.maxGroupTieredPackageConfig - modelType = newSubscriptionMaxGroupTieredPackagePrice.modelType - name = newSubscriptionMaxGroupTieredPackagePrice.name - billableMetricId = - newSubscriptionMaxGroupTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionMaxGroupTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMaxGroupTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionMaxGroupTieredPackagePrice.conversionRate - currency = newSubscriptionMaxGroupTieredPackagePrice.currency - externalPriceId = newSubscriptionMaxGroupTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionMaxGroupTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionMaxGroupTieredPackagePrice.invoiceGroupingKey + maxGroupTieredPackage.maxGroupTieredPackageConfig + modelType = maxGroupTieredPackage.modelType + name = maxGroupTieredPackage.name + billableMetricId = maxGroupTieredPackage.billableMetricId + billedInAdvance = maxGroupTieredPackage.billedInAdvance + billingCycleConfiguration = maxGroupTieredPackage.billingCycleConfiguration + conversionRate = maxGroupTieredPackage.conversionRate + currency = maxGroupTieredPackage.currency + externalPriceId = maxGroupTieredPackage.externalPriceId + fixedPriceQuantity = maxGroupTieredPackage.fixedPriceQuantity + invoiceGroupingKey = maxGroupTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionMaxGroupTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionMaxGroupTieredPackagePrice.metadata - referenceId = newSubscriptionMaxGroupTieredPackagePrice.referenceId + maxGroupTieredPackage.invoicingCycleConfiguration + metadata = maxGroupTieredPackage.metadata + referenceId = maxGroupTieredPackage.referenceId additionalProperties = - newSubscriptionMaxGroupTieredPackagePrice.additionalProperties - .toMutableMap() + maxGroupTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -122241,18 +113469,19 @@ private constructor( maxGroupTieredPackageConfig: JsonField ) = apply { this.maxGroupTieredPackageConfig = maxGroupTieredPackageConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("max_group_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -122573,7 +113802,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMaxGroupTieredPackagePrice]. + * Returns an immutable instance of [MaxGroupTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -122582,21 +113811,20 @@ private constructor( * .cadence() * .itemId() * .maxGroupTieredPackageConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMaxGroupTieredPackagePrice = - NewSubscriptionMaxGroupTieredPackagePrice( + fun build(): MaxGroupTieredPackage = + MaxGroupTieredPackage( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired( "maxGroupTieredPackageConfig", maxGroupTieredPackageConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -122615,7 +113843,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMaxGroupTieredPackagePrice = apply { + fun validate(): MaxGroupTieredPackage = apply { if (validated) { return@apply } @@ -122623,7 +113851,11 @@ private constructor( cadence().validate() itemId() maxGroupTieredPackageConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("max_group_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -122658,7 +113890,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (maxGroupTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("max_group_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -122946,135 +114180,6 @@ private constructor( "MaxGroupTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MAX_GROUP_TIERED_PACKAGE = of("max_group_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MAX_GROUP_TIERED_PACKAGE - } - - /** - * 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 { - MAX_GROUP_TIERED_PACKAGE, - /** - * 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) { - MAX_GROUP_TIERED_PACKAGE -> Value.MAX_GROUP_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAX_GROUP_TIERED_PACKAGE -> Known.MAX_GROUP_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -123913,7 +115018,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MaxGroupTieredPackage && 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 && currency == other.currency && 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 */ @@ -123923,16 +115028,16 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMaxGroupTieredPackagePrice{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MaxGroupTieredPackage{cadence=$cadence, itemId=$itemId, maxGroupTieredPackageConfig=$maxGroupTieredPackageConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedWithMeteredMinimumPrice + class GroupedWithMeteredMinimum private constructor( private val cadence: JsonField, private val groupedWithMeteredMinimumConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -123962,7 +115067,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -124050,11 +115155,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -124199,16 +115308,6 @@ private constructor( */ @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]. * @@ -124345,21 +115444,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedWithMeteredMinimumPrice]. + * [GroupedWithMeteredMinimum]. * * The following fields are required: * ```java * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedWithMeteredMinimumPrice]. */ + /** A builder for [GroupedWithMeteredMinimum]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -124367,7 +115465,8 @@ private constructor( JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = + JsonValue.from("grouped_with_metered_minimum") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -124386,41 +115485,30 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedWithMeteredMinimumPrice: - NewSubscriptionGroupedWithMeteredMinimumPrice - ) = apply { - cadence = newSubscriptionGroupedWithMeteredMinimumPrice.cadence - groupedWithMeteredMinimumConfig = - newSubscriptionGroupedWithMeteredMinimumPrice - .groupedWithMeteredMinimumConfig - itemId = newSubscriptionGroupedWithMeteredMinimumPrice.itemId - modelType = newSubscriptionGroupedWithMeteredMinimumPrice.modelType - name = newSubscriptionGroupedWithMeteredMinimumPrice.name - billableMetricId = - newSubscriptionGroupedWithMeteredMinimumPrice.billableMetricId - billedInAdvance = - newSubscriptionGroupedWithMeteredMinimumPrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedWithMeteredMinimumPrice.billingCycleConfiguration - conversionRate = - newSubscriptionGroupedWithMeteredMinimumPrice.conversionRate - currency = newSubscriptionGroupedWithMeteredMinimumPrice.currency - externalPriceId = - newSubscriptionGroupedWithMeteredMinimumPrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedWithMeteredMinimumPrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedWithMeteredMinimumPrice.invoiceGroupingKey - invoicingCycleConfiguration = - newSubscriptionGroupedWithMeteredMinimumPrice - .invoicingCycleConfiguration - metadata = newSubscriptionGroupedWithMeteredMinimumPrice.metadata - referenceId = newSubscriptionGroupedWithMeteredMinimumPrice.referenceId - additionalProperties = - newSubscriptionGroupedWithMeteredMinimumPrice.additionalProperties - .toMutableMap() - } + internal fun from(groupedWithMeteredMinimum: GroupedWithMeteredMinimum) = + apply { + cadence = groupedWithMeteredMinimum.cadence + groupedWithMeteredMinimumConfig = + groupedWithMeteredMinimum.groupedWithMeteredMinimumConfig + itemId = groupedWithMeteredMinimum.itemId + modelType = groupedWithMeteredMinimum.modelType + name = groupedWithMeteredMinimum.name + billableMetricId = groupedWithMeteredMinimum.billableMetricId + billedInAdvance = groupedWithMeteredMinimum.billedInAdvance + billingCycleConfiguration = + groupedWithMeteredMinimum.billingCycleConfiguration + conversionRate = groupedWithMeteredMinimum.conversionRate + currency = groupedWithMeteredMinimum.currency + externalPriceId = groupedWithMeteredMinimum.externalPriceId + fixedPriceQuantity = groupedWithMeteredMinimum.fixedPriceQuantity + invoiceGroupingKey = groupedWithMeteredMinimum.invoiceGroupingKey + invoicingCycleConfiguration = + groupedWithMeteredMinimum.invoicingCycleConfiguration + metadata = groupedWithMeteredMinimum.metadata + referenceId = groupedWithMeteredMinimum.referenceId + additionalProperties = + groupedWithMeteredMinimum.additionalProperties.toMutableMap() + } /** The cadence to bill for this price on. */ fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) @@ -124467,18 +115555,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_with_metered_minimum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -124799,8 +115888,7 @@ private constructor( } /** - * Returns an immutable instance of - * [NewSubscriptionGroupedWithMeteredMinimumPrice]. + * Returns an immutable instance of [GroupedWithMeteredMinimum]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -124809,21 +115897,20 @@ private constructor( * .cadence() * .groupedWithMeteredMinimumConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedWithMeteredMinimumPrice = - NewSubscriptionGroupedWithMeteredMinimumPrice( + fun build(): GroupedWithMeteredMinimum = + GroupedWithMeteredMinimum( checkRequired("cadence", cadence), checkRequired( "groupedWithMeteredMinimumConfig", groupedWithMeteredMinimumConfig, ), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -124842,7 +115929,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedWithMeteredMinimumPrice = apply { + fun validate(): GroupedWithMeteredMinimum = apply { if (validated) { return@apply } @@ -124850,7 +115937,11 @@ private constructor( cadence().validate() groupedWithMeteredMinimumConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_with_metered_minimum")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -124885,7 +115976,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedWithMeteredMinimumConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_with_metered_minimum")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -125173,136 +116266,6 @@ private constructor( "GroupedWithMeteredMinimumConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField - val GROUPED_WITH_METERED_MINIMUM = of("grouped_with_metered_minimum") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_WITH_METERED_MINIMUM - } - - /** - * An enum containing [ModelType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ModelType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUPED_WITH_METERED_MINIMUM, - /** - * An enum member indicating that [ModelType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Value.GROUPED_WITH_METERED_MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_WITH_METERED_MINIMUM -> Known.GROUPED_WITH_METERED_MINIMUM - else -> throw OrbInvalidDataException("Unknown ModelType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws OrbInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -126141,7 +117104,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedWithMeteredMinimum && 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 && currency == other.currency && 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 */ @@ -126151,15 +117114,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedWithMeteredMinimumPrice{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedWithMeteredMinimum{cadence=$cadence, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionMatrixWithDisplayNamePrice + class MatrixWithDisplayName private constructor( private val cadence: JsonField, private val itemId: JsonField, private val matrixWithDisplayNameConfig: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -126189,7 +117152,7 @@ private constructor( JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -126275,11 +117238,15 @@ private constructor( matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_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). + * Expected to always return the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -126424,16 +117391,6 @@ private constructor( fun _matrixWithDisplayNameConfig(): JsonField = matrixWithDisplayNameConfig - /** - * 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]. * @@ -126570,21 +117527,20 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionMatrixWithDisplayNamePrice]. + * [MatrixWithDisplayName]. * * The following fields are required: * ```java * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionMatrixWithDisplayNamePrice]. */ + /** A builder for [MatrixWithDisplayName]. */ class Builder internal constructor() { private var cadence: JsonField? = null @@ -126592,7 +117548,7 @@ private constructor( private var matrixWithDisplayNameConfig: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("matrix_with_display_name") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -126611,35 +117567,27 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionMatrixWithDisplayNamePrice: - NewSubscriptionMatrixWithDisplayNamePrice - ) = apply { - cadence = newSubscriptionMatrixWithDisplayNamePrice.cadence - itemId = newSubscriptionMatrixWithDisplayNamePrice.itemId + internal fun from(matrixWithDisplayName: MatrixWithDisplayName) = apply { + cadence = matrixWithDisplayName.cadence + itemId = matrixWithDisplayName.itemId matrixWithDisplayNameConfig = - newSubscriptionMatrixWithDisplayNamePrice.matrixWithDisplayNameConfig - modelType = newSubscriptionMatrixWithDisplayNamePrice.modelType - name = newSubscriptionMatrixWithDisplayNamePrice.name - billableMetricId = - newSubscriptionMatrixWithDisplayNamePrice.billableMetricId - billedInAdvance = newSubscriptionMatrixWithDisplayNamePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionMatrixWithDisplayNamePrice.billingCycleConfiguration - conversionRate = newSubscriptionMatrixWithDisplayNamePrice.conversionRate - currency = newSubscriptionMatrixWithDisplayNamePrice.currency - externalPriceId = newSubscriptionMatrixWithDisplayNamePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionMatrixWithDisplayNamePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionMatrixWithDisplayNamePrice.invoiceGroupingKey + matrixWithDisplayName.matrixWithDisplayNameConfig + modelType = matrixWithDisplayName.modelType + name = matrixWithDisplayName.name + billableMetricId = matrixWithDisplayName.billableMetricId + billedInAdvance = matrixWithDisplayName.billedInAdvance + billingCycleConfiguration = matrixWithDisplayName.billingCycleConfiguration + conversionRate = matrixWithDisplayName.conversionRate + currency = matrixWithDisplayName.currency + externalPriceId = matrixWithDisplayName.externalPriceId + fixedPriceQuantity = matrixWithDisplayName.fixedPriceQuantity + invoiceGroupingKey = matrixWithDisplayName.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionMatrixWithDisplayNamePrice.invoicingCycleConfiguration - metadata = newSubscriptionMatrixWithDisplayNamePrice.metadata - referenceId = newSubscriptionMatrixWithDisplayNamePrice.referenceId + matrixWithDisplayName.invoicingCycleConfiguration + metadata = matrixWithDisplayName.metadata + referenceId = matrixWithDisplayName.referenceId additionalProperties = - newSubscriptionMatrixWithDisplayNamePrice.additionalProperties - .toMutableMap() + matrixWithDisplayName.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -126682,18 +117630,19 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("matrix_with_display_name") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -127014,7 +117963,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionMatrixWithDisplayNamePrice]. + * Returns an immutable instance of [MatrixWithDisplayName]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -127023,21 +117972,20 @@ private constructor( * .cadence() * .itemId() * .matrixWithDisplayNameConfig() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionMatrixWithDisplayNamePrice = - NewSubscriptionMatrixWithDisplayNamePrice( + fun build(): MatrixWithDisplayName = + MatrixWithDisplayName( checkRequired("cadence", cadence), checkRequired("itemId", itemId), checkRequired( "matrixWithDisplayNameConfig", matrixWithDisplayNameConfig, ), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -127056,7 +118004,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionMatrixWithDisplayNamePrice = apply { + fun validate(): MatrixWithDisplayName = apply { if (validated) { return@apply } @@ -127064,7 +118012,11 @@ private constructor( cadence().validate() itemId() matrixWithDisplayNameConfig().validate() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("matrix_with_display_name")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -127099,7 +118051,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + (matrixWithDisplayNameConfig.asKnown().getOrNull()?.validity() ?: 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("matrix_with_display_name")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -127387,135 +118341,6 @@ private constructor( "MatrixWithDisplayNameConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MATRIX_WITH_DISPLAY_NAME = of("matrix_with_display_name") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - MATRIX_WITH_DISPLAY_NAME - } - - /** - * 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 { - MATRIX_WITH_DISPLAY_NAME, - /** - * 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) { - MATRIX_WITH_DISPLAY_NAME -> Value.MATRIX_WITH_DISPLAY_NAME - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MATRIX_WITH_DISPLAY_NAME -> Known.MATRIX_WITH_DISPLAY_NAME - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -128354,7 +119179,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is MatrixWithDisplayName && 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 && currency == other.currency && 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 */ @@ -128364,15 +119189,15 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionMatrixWithDisplayNamePrice{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "MatrixWithDisplayName{cadence=$cadence, itemId=$itemId, matrixWithDisplayNameConfig=$matrixWithDisplayNameConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" } - class NewSubscriptionGroupedTieredPackagePrice + class GroupedTieredPackage private constructor( private val cadence: JsonField, private val groupedTieredPackageConfig: JsonField, private val itemId: JsonField, - private val modelType: JsonField, + private val modelType: JsonValue, private val name: JsonField, private val billableMetricId: JsonField, private val billedInAdvance: JsonField, @@ -128402,7 +119227,7 @@ private constructor( itemId: JsonField = JsonMissing.of(), @JsonProperty("model_type") @ExcludeMissing - modelType: JsonField = JsonMissing.of(), + modelType: JsonValue = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @@ -128488,11 +119313,15 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun modelType(): ModelType = modelType.getRequired("model_type") + @JsonProperty("model_type") @ExcludeMissing fun _modelType(): JsonValue = modelType /** * The name of the price. @@ -128637,16 +119466,6 @@ private constructor( */ @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]. * @@ -128783,28 +119602,27 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [NewSubscriptionGroupedTieredPackagePrice]. + * [GroupedTieredPackage]. * * The following fields are required: * ```java * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [NewSubscriptionGroupedTieredPackagePrice]. */ + /** A builder for [GroupedTieredPackage]. */ class Builder internal constructor() { private var cadence: JsonField? = null private var groupedTieredPackageConfig: JsonField? = null private var itemId: JsonField? = null - private var modelType: JsonField? = null + private var modelType: JsonValue = JsonValue.from("grouped_tiered_package") private var name: JsonField? = null private var billableMetricId: JsonField = JsonMissing.of() private var billedInAdvance: JsonField = JsonMissing.of() @@ -128823,34 +119641,26 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - newSubscriptionGroupedTieredPackagePrice: - NewSubscriptionGroupedTieredPackagePrice - ) = apply { - cadence = newSubscriptionGroupedTieredPackagePrice.cadence - groupedTieredPackageConfig = - newSubscriptionGroupedTieredPackagePrice.groupedTieredPackageConfig - itemId = newSubscriptionGroupedTieredPackagePrice.itemId - modelType = newSubscriptionGroupedTieredPackagePrice.modelType - name = newSubscriptionGroupedTieredPackagePrice.name - billableMetricId = newSubscriptionGroupedTieredPackagePrice.billableMetricId - billedInAdvance = newSubscriptionGroupedTieredPackagePrice.billedInAdvance - billingCycleConfiguration = - newSubscriptionGroupedTieredPackagePrice.billingCycleConfiguration - conversionRate = newSubscriptionGroupedTieredPackagePrice.conversionRate - currency = newSubscriptionGroupedTieredPackagePrice.currency - externalPriceId = newSubscriptionGroupedTieredPackagePrice.externalPriceId - fixedPriceQuantity = - newSubscriptionGroupedTieredPackagePrice.fixedPriceQuantity - invoiceGroupingKey = - newSubscriptionGroupedTieredPackagePrice.invoiceGroupingKey + internal fun from(groupedTieredPackage: GroupedTieredPackage) = apply { + cadence = groupedTieredPackage.cadence + groupedTieredPackageConfig = groupedTieredPackage.groupedTieredPackageConfig + itemId = groupedTieredPackage.itemId + modelType = groupedTieredPackage.modelType + name = groupedTieredPackage.name + billableMetricId = groupedTieredPackage.billableMetricId + billedInAdvance = groupedTieredPackage.billedInAdvance + billingCycleConfiguration = groupedTieredPackage.billingCycleConfiguration + conversionRate = groupedTieredPackage.conversionRate + currency = groupedTieredPackage.currency + externalPriceId = groupedTieredPackage.externalPriceId + fixedPriceQuantity = groupedTieredPackage.fixedPriceQuantity + invoiceGroupingKey = groupedTieredPackage.invoiceGroupingKey invoicingCycleConfiguration = - newSubscriptionGroupedTieredPackagePrice.invoicingCycleConfiguration - metadata = newSubscriptionGroupedTieredPackagePrice.metadata - referenceId = newSubscriptionGroupedTieredPackagePrice.referenceId + groupedTieredPackage.invoicingCycleConfiguration + metadata = groupedTieredPackage.metadata + referenceId = groupedTieredPackage.referenceId additionalProperties = - newSubscriptionGroupedTieredPackagePrice.additionalProperties - .toMutableMap() + groupedTieredPackage.additionalProperties.toMutableMap() } /** The cadence to bill for this price on. */ @@ -128893,18 +119703,19 @@ private constructor( */ fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - /** - * Sets [Builder.modelType] to an arbitrary JSON value. + * Sets the field 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. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("grouped_tiered_package") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun modelType(modelType: JsonField) = apply { - this.modelType = modelType - } + fun modelType(modelType: JsonValue) = apply { this.modelType = modelType } /** The name of the price. */ fun name(name: String) = name(JsonField.of(name)) @@ -129225,7 +120036,7 @@ private constructor( } /** - * Returns an immutable instance of [NewSubscriptionGroupedTieredPackagePrice]. + * Returns an immutable instance of [GroupedTieredPackage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -129234,18 +120045,17 @@ private constructor( * .cadence() * .groupedTieredPackageConfig() * .itemId() - * .modelType() * .name() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): NewSubscriptionGroupedTieredPackagePrice = - NewSubscriptionGroupedTieredPackagePrice( + fun build(): GroupedTieredPackage = + GroupedTieredPackage( checkRequired("cadence", cadence), checkRequired("groupedTieredPackageConfig", groupedTieredPackageConfig), checkRequired("itemId", itemId), - checkRequired("modelType", modelType), + modelType, checkRequired("name", name), billableMetricId, billedInAdvance, @@ -129264,7 +120074,7 @@ private constructor( private var validated: Boolean = false - fun validate(): NewSubscriptionGroupedTieredPackagePrice = apply { + fun validate(): GroupedTieredPackage = apply { if (validated) { return@apply } @@ -129272,7 +120082,11 @@ private constructor( cadence().validate() groupedTieredPackageConfig().validate() itemId() - modelType().validate() + _modelType().let { + if (it != JsonValue.from("grouped_tiered_package")) { + throw OrbInvalidDataException("'modelType' is invalid, received $it") + } + } name() billableMetricId() billedInAdvance() @@ -129307,7 +120121,9 @@ private constructor( (cadence.asKnown().getOrNull()?.validity() ?: 0) + (groupedTieredPackageConfig.asKnown().getOrNull()?.validity() ?: 0) + (if (itemId.asKnown().isPresent) 1 else 0) + - (modelType.asKnown().getOrNull()?.validity() ?: 0) + + modelType.let { + if (it == JsonValue.from("grouped_tiered_package")) 1 else 0 + } + (if (name.asKnown().isPresent) 1 else 0) + (if (billableMetricId.asKnown().isPresent) 1 else 0) + (if (billedInAdvance.asKnown().isPresent) 1 else 0) + @@ -129594,135 +120410,6 @@ private constructor( "GroupedTieredPackageConfig{additionalProperties=$additionalProperties}" } - class ModelType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUPED_TIERED_PACKAGE = of("grouped_tiered_package") - - @JvmStatic fun of(value: String) = ModelType(JsonField.of(value)) - } - - /** An enum containing [ModelType]'s known values. */ - enum class Known { - GROUPED_TIERED_PACKAGE - } - - /** - * 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 { - GROUPED_TIERED_PACKAGE, - /** - * 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) { - GROUPED_TIERED_PACKAGE -> Value.GROUPED_TIERED_PACKAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUPED_TIERED_PACKAGE -> Known.GROUPED_TIERED_PACKAGE - 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() - } - /** * For custom cadence: specifies the duration of the billing period in days or * months. @@ -130561,7 +121248,7 @@ 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 && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && referenceId == other.referenceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is GroupedTieredPackage && 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 && currency == other.currency && 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 */ @@ -130571,7 +121258,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "NewSubscriptionGroupedTieredPackagePrice{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, referenceId=$referenceId, additionalProperties=$additionalProperties}" + "GroupedTieredPackage{cadence=$cadence, groupedTieredPackageConfig=$groupedTieredPackageConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, 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/SubscriptionSchedulePlanChangeResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt index f105c093..3a1a1d99 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt @@ -1068,17 +1068,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1722,41 +1722,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1905,66 +1892,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1977,34 +1954,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2029,25 +1998,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2058,21 +2021,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2080,27 +2041,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2109,21 +2063,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2149,44 +2097,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2202,26 +2135,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2235,7 +2164,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2270,11 +2199,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2330,16 +2265,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2403,13 +2328,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2420,11 +2343,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2433,21 +2356,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2461,17 +2379,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2606,14 +2526,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2623,10 +2542,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2640,13 +2559,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2672,149 +2597,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2824,13 +2621,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2844,7 +2641,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2879,11 +2676,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2939,16 +2742,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3012,13 +2805,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3029,11 +2820,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3042,21 +2833,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3070,17 +2856,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3215,14 +3003,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3232,10 +3019,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3249,13 +3036,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3281,149 +3074,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3433,13 +3098,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3453,7 +3118,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3488,11 +3153,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3549,16 +3220,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3623,12 +3284,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3639,11 +3299,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3652,23 +3312,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3682,17 +3336,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3827,14 +3483,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3844,10 +3499,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3861,13 +3516,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3893,149 +3554,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4045,13 +3578,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4066,7 +3599,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4105,11 +3638,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4175,19 +3714,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4255,13 +3784,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4273,11 +3800,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4287,22 +3814,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4315,17 +3837,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4472,14 +3996,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4490,10 +4013,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4508,13 +4031,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4541,7 +4070,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4549,142 +4078,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4694,13 +4093,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4714,7 +4113,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4749,11 +4148,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4809,16 +4214,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4882,13 +4277,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4899,11 +4292,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4912,21 +4305,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4939,17 +4327,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5084,14 +4474,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5101,10 +4490,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5118,13 +4507,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5150,149 +4545,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5302,7 +4567,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5595,17 +4860,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5613,11 +4878,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5638,15 +4903,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5672,12 +4937,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5704,14 +4968,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5720,11 +4982,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5750,17 +5012,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5787,12 +5049,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5811,7 +5073,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5858,11 +5120,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5911,16 +5179,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5955,15 +5213,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5971,29 +5227,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6068,17 +5322,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6134,7 +5390,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6143,15 +5399,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6159,7 +5414,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6168,7 +5423,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6176,7 +5431,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6201,143 +5460,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6347,14 +5479,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6371,7 +5503,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6412,11 +5544,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6464,16 +5602,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6518,14 +5646,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6534,31 +5660,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6618,17 +5740,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6701,7 +5825,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6709,7 +5833,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6717,15 +5840,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6735,14 +5858,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6767,144 +5894,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6914,14 +5914,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6938,7 +5938,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6979,11 +5979,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7032,16 +6038,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7086,14 +6082,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7102,28 +6096,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7183,17 +6176,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7267,7 +6262,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7275,7 +6270,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7283,15 +6277,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7301,14 +6295,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7333,144 +6331,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7480,7 +6351,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9280,142 +8151,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 848386a2..c92bb563 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 @@ -11,7 +11,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException @@ -24,13 +23,13 @@ import kotlin.jvm.optionals.getOrNull /** Manually trigger a phase, effective the given date (or the current time, if not specified). */ class SubscriptionTriggerPhaseParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * If false, this request will fail if it would void an issued invoice or create a credit note. @@ -76,14 +75,11 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionTriggerPhaseParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [SubscriptionTriggerPhaseParams]. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -104,7 +100,11 @@ private constructor( additionalQueryParams = subscriptionTriggerPhaseParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Sets the entire request body. @@ -293,17 +293,10 @@ private constructor( * Returns an immutable instance of [SubscriptionTriggerPhaseParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -314,7 +307,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt index b2206c15..f3aa4d8b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt @@ -1065,17 +1065,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1719,41 +1719,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1902,66 +1889,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1974,34 +1951,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2026,25 +1995,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2055,21 +2018,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2077,27 +2038,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2106,21 +2060,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2146,44 +2094,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2199,26 +2132,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2232,7 +2161,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2267,11 +2196,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2327,16 +2262,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2400,13 +2325,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2417,11 +2340,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2430,21 +2353,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2458,17 +2376,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2603,14 +2523,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2620,10 +2539,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2637,13 +2556,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2669,149 +2594,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2821,13 +2618,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2841,7 +2638,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2876,11 +2673,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2936,16 +2739,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3009,13 +2802,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3026,11 +2817,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3039,21 +2830,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3067,17 +2853,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3212,14 +3000,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3229,10 +3016,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3246,13 +3033,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3278,149 +3071,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3430,13 +3095,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3450,7 +3115,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3485,11 +3150,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3546,16 +3217,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3620,12 +3281,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3636,11 +3296,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3649,23 +3309,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3679,17 +3333,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3824,14 +3480,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3841,10 +3496,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3858,13 +3513,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3890,149 +3551,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4042,13 +3575,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4063,7 +3596,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4102,11 +3635,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4172,19 +3711,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4252,13 +3781,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4270,11 +3797,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4284,22 +3811,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4312,17 +3834,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4469,14 +3993,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4487,10 +4010,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4505,13 +4028,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4538,7 +4067,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4546,142 +4075,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4691,13 +4090,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4711,7 +4110,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4746,11 +4145,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4806,16 +4211,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4879,13 +4274,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4896,11 +4289,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4909,21 +4302,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4936,17 +4324,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5081,14 +4471,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5098,10 +4487,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5115,13 +4504,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5147,149 +4542,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5299,7 +4564,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5592,17 +4857,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5610,11 +4875,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5635,15 +4900,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5669,12 +4934,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5701,14 +4965,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5717,11 +4979,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5747,17 +5009,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5784,12 +5046,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5808,7 +5070,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5855,11 +5117,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5908,16 +5176,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5952,15 +5210,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5968,29 +5224,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6065,17 +5319,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6131,7 +5387,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6140,15 +5396,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6156,7 +5411,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6165,7 +5420,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6173,7 +5428,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6198,143 +5457,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6344,14 +5476,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6368,7 +5500,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6409,11 +5541,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6461,16 +5599,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6515,14 +5643,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6531,31 +5657,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6615,17 +5737,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6698,7 +5822,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6706,7 +5830,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6714,15 +5837,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6732,14 +5855,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6764,144 +5891,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6911,14 +5911,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6935,7 +5935,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6976,11 +5976,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7029,16 +6035,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7083,14 +6079,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7099,28 +6093,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7180,17 +6173,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7264,7 +6259,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7272,7 +6267,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7280,15 +6274,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7298,14 +6292,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7330,144 +6328,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7477,7 +6348,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9277,142 +8148,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 714841c7..12927d89 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 @@ -4,12 +4,12 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint can be used to unschedule any pending cancellations for a subscription. @@ -20,13 +20,13 @@ import java.util.Optional */ class SubscriptionUnscheduleCancellationParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -38,14 +38,11 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionUnscheduleCancellationParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [SubscriptionUnscheduleCancellationParams]. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -71,7 +68,11 @@ private constructor( subscriptionUnscheduleCancellationParams.additionalBodyProperties.toMutableMap() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -197,17 +198,10 @@ private constructor( * Returns an immutable instance of [SubscriptionUnscheduleCancellationParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionUnscheduleCancellationParams = SubscriptionUnscheduleCancellationParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -219,7 +213,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt index 3594ee80..7f49483f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt @@ -1074,17 +1074,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1728,41 +1728,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1911,66 +1898,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1983,34 +1960,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2035,25 +2004,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2064,21 +2027,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2086,27 +2047,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2115,21 +2069,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2155,44 +2103,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2208,26 +2141,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2241,7 +2170,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2276,11 +2205,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2336,16 +2271,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2409,13 +2334,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2426,11 +2349,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2439,21 +2362,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2467,17 +2385,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2612,14 +2532,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2629,10 +2548,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2646,13 +2565,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2678,149 +2603,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2830,13 +2627,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2850,7 +2647,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2885,11 +2682,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2945,16 +2748,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3018,13 +2811,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3035,11 +2826,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3048,21 +2839,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3076,17 +2862,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3221,14 +3009,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3238,10 +3025,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3255,13 +3042,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3287,149 +3080,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3439,13 +3104,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3459,7 +3124,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3494,11 +3159,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3555,16 +3226,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3629,12 +3290,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3645,11 +3305,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3658,23 +3318,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3688,17 +3342,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3833,14 +3489,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3850,10 +3505,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3867,13 +3522,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3899,149 +3560,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4051,13 +3584,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4072,7 +3605,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4111,11 +3644,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4181,19 +3720,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4261,13 +3790,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4279,11 +3806,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4293,22 +3820,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4321,17 +3843,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4478,14 +4002,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4496,10 +4019,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4514,13 +4037,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4547,7 +4076,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4555,142 +4084,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4700,13 +4099,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4720,7 +4119,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4755,11 +4154,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4815,16 +4220,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4888,13 +4283,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4905,11 +4298,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4918,21 +4311,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4945,17 +4333,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5090,14 +4480,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5107,10 +4496,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5124,13 +4513,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5156,149 +4551,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5308,7 +4573,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5601,17 +4866,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5619,11 +4884,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5644,15 +4909,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5678,12 +4943,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5710,14 +4974,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5726,11 +4988,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5756,17 +5018,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5793,12 +5055,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5817,7 +5079,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5864,11 +5126,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5917,16 +5185,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5961,15 +5219,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5977,29 +5233,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6074,17 +5328,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6140,7 +5396,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6149,15 +5405,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6165,7 +5420,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6174,7 +5429,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6182,7 +5437,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6207,143 +5466,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6353,14 +5485,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6377,7 +5509,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6418,11 +5550,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6470,16 +5608,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6524,14 +5652,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6540,31 +5666,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6624,17 +5746,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6707,7 +5831,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6715,7 +5839,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6723,15 +5846,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6741,14 +5864,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6773,144 +5900,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6920,14 +5920,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6944,7 +5944,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6985,11 +5985,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7038,16 +6044,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7092,14 +6088,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7108,28 +6102,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7189,17 +6182,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7273,7 +6268,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7281,7 +6276,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7289,15 +6283,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7307,14 +6301,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7339,144 +6337,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7486,7 +6357,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9286,142 +8157,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 2181822e..b04fb950 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 @@ -17,6 +17,8 @@ import com.withorb.api.core.http.QueryParams import com.withorb.api.errors.OrbInvalidDataException import java.util.Collections import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. @@ -26,13 +28,13 @@ import java.util.Objects */ class SubscriptionUnscheduleFixedFeeQuantityUpdatesParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * Price for which the updates should be cleared. Must be a fixed fee. @@ -65,7 +67,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .priceId() * ``` */ @@ -94,7 +95,11 @@ private constructor( .toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Sets the entire request body. @@ -240,7 +245,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .priceId() * ``` * @@ -248,7 +252,7 @@ private constructor( */ fun build(): SubscriptionUnscheduleFixedFeeQuantityUpdatesParams = SubscriptionUnscheduleFixedFeeQuantityUpdatesParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -259,7 +263,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt index d9f8a26e..02cefb2e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt @@ -1083,17 +1083,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1737,41 +1737,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1920,66 +1907,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1992,34 +1969,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2044,25 +2013,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2073,21 +2036,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2095,27 +2056,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2124,21 +2078,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2164,44 +2112,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2217,26 +2150,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2250,7 +2179,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2285,11 +2214,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2345,16 +2280,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2418,13 +2343,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2435,11 +2358,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2448,21 +2371,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2476,17 +2394,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2621,14 +2541,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2638,10 +2557,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2655,13 +2574,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2687,149 +2612,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2839,13 +2636,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2859,7 +2656,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2894,11 +2691,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2954,16 +2757,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3027,13 +2820,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3044,11 +2835,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3057,21 +2848,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3085,17 +2871,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3230,14 +3018,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3247,10 +3034,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3264,13 +3051,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3296,149 +3089,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3448,13 +3113,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3468,7 +3133,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3503,11 +3168,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3564,16 +3235,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3638,12 +3299,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3654,11 +3314,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3667,23 +3327,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3697,17 +3351,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3842,14 +3498,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3859,10 +3514,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3876,13 +3531,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3908,149 +3569,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4060,13 +3593,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4081,7 +3614,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4120,11 +3653,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4190,19 +3729,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4270,13 +3799,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4288,11 +3815,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4302,22 +3829,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4330,17 +3852,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4487,14 +4011,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4505,10 +4028,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4523,13 +4046,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4556,7 +4085,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4564,142 +4093,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4709,13 +4108,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4729,7 +4128,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4764,11 +4163,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4824,16 +4229,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4897,13 +4292,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4914,11 +4307,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4927,21 +4320,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4954,17 +4342,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5099,14 +4489,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5116,10 +4505,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5133,13 +4522,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5165,149 +4560,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5317,7 +4582,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5610,17 +4875,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5628,11 +4893,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5653,15 +4918,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5687,12 +4952,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5719,14 +4983,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5735,11 +4997,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5765,17 +5027,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5802,12 +5064,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5826,7 +5088,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5873,11 +5135,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5926,16 +5194,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5970,15 +5228,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5986,29 +5242,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6083,17 +5337,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6149,7 +5405,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6158,15 +5414,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6174,7 +5429,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6183,7 +5438,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6191,7 +5446,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6216,143 +5475,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6362,14 +5494,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6386,7 +5518,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6427,11 +5559,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6479,16 +5617,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6533,14 +5661,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6549,31 +5675,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6633,17 +5755,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6716,7 +5840,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6724,7 +5848,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6732,15 +5855,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6750,14 +5873,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6782,144 +5909,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6929,14 +5929,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6953,7 +5953,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6994,11 +5994,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7047,16 +6053,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7101,14 +6097,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7117,28 +6111,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7198,17 +6191,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7282,7 +6277,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7290,7 +6285,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7298,15 +6292,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7316,14 +6310,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7348,144 +6346,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7495,7 +6366,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9295,142 +8166,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 925e9578..c05025a0 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 @@ -4,23 +4,23 @@ package com.withorb.api.models import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** This endpoint can be used to unschedule any pending plan changes on an existing subscription. */ class SubscriptionUnschedulePendingPlanChangesParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) fun _additionalBodyProperties(): Map = additionalBodyProperties @@ -32,14 +32,11 @@ private constructor( companion object { + @JvmStatic fun none(): SubscriptionUnschedulePendingPlanChangesParams = builder().build() + /** * Returns a mutable builder for constructing an instance of * [SubscriptionUnschedulePendingPlanChangesParams]. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` */ @JvmStatic fun builder() = Builder() } @@ -67,7 +64,11 @@ private constructor( .toMutableMap() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -193,17 +194,10 @@ private constructor( * Returns an immutable instance of [SubscriptionUnschedulePendingPlanChangesParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionUnschedulePendingPlanChangesParams = SubscriptionUnschedulePendingPlanChangesParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), @@ -215,7 +209,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt index cd3acd27..2605a4d8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt @@ -1078,17 +1078,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1732,41 +1732,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1915,66 +1902,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1987,34 +1964,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2039,25 +2008,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2068,21 +2031,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2090,27 +2051,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2119,21 +2073,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2159,44 +2107,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2212,26 +2145,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2245,7 +2174,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2280,11 +2209,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2340,16 +2275,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2413,13 +2338,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2430,11 +2353,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2443,21 +2366,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2471,17 +2389,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2616,14 +2536,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2633,10 +2552,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2650,13 +2569,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2682,149 +2607,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2834,13 +2631,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2854,7 +2651,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2889,11 +2686,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2949,16 +2752,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3022,13 +2815,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3039,11 +2830,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3052,21 +2843,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3080,17 +2866,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3225,14 +3013,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3242,10 +3029,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3259,13 +3046,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3291,149 +3084,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3443,13 +3108,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3463,7 +3128,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3498,11 +3163,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3559,16 +3230,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3633,12 +3294,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3649,11 +3309,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3662,23 +3322,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3692,17 +3346,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3837,14 +3493,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3854,10 +3509,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3871,13 +3526,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3903,149 +3564,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4055,13 +3588,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4076,7 +3609,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4115,11 +3648,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4185,19 +3724,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4265,13 +3794,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4283,11 +3810,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4297,22 +3824,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4325,17 +3847,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4482,14 +4006,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4500,10 +4023,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4518,13 +4041,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4551,7 +4080,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4559,142 +4088,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4704,13 +4103,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4724,7 +4123,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4759,11 +4158,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4819,16 +4224,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4892,13 +4287,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4909,11 +4302,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4922,21 +4315,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4949,17 +4337,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5094,14 +4484,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5111,10 +4500,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5128,13 +4517,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5160,149 +4555,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5312,7 +4577,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5605,17 +4870,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5623,11 +4888,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5648,15 +4913,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5682,12 +4947,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5714,14 +4978,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5730,11 +4992,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5760,17 +5022,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5797,12 +5059,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5821,7 +5083,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5868,11 +5130,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5921,16 +5189,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5965,15 +5223,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5981,29 +5237,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6078,17 +5332,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6144,7 +5400,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6153,15 +5409,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6169,7 +5424,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6178,7 +5433,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6186,7 +5441,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6211,143 +5470,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6357,14 +5489,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6381,7 +5513,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6422,11 +5554,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6474,16 +5612,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6528,14 +5656,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6544,31 +5670,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6628,17 +5750,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6711,7 +5835,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6719,7 +5843,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6727,15 +5850,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6745,14 +5868,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6777,144 +5904,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6924,14 +5924,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6948,7 +5948,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6989,11 +5989,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7042,16 +6048,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7096,14 +6092,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7112,28 +6106,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7193,17 +6186,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7277,7 +6272,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7285,7 +6280,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7293,15 +6287,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7311,14 +6305,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7343,144 +6341,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7490,7 +6361,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9290,142 +8161,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 653b3640..1fd60e25 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 @@ -38,13 +38,13 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionUpdateFixedFeeQuantityParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * Price for which the quantity should be updated. Must be a fixed fee. @@ -142,7 +142,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .priceId() * .quantity() * ``` @@ -170,7 +169,11 @@ private constructor( subscriptionUpdateFixedFeeQuantityParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Sets the entire request body. @@ -406,7 +409,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .priceId() * .quantity() * ``` @@ -415,7 +417,7 @@ private constructor( */ fun build(): SubscriptionUpdateFixedFeeQuantityParams = SubscriptionUpdateFixedFeeQuantityParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -426,7 +428,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt index d39d6856..878b1068 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt @@ -1074,17 +1074,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1728,41 +1728,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1911,66 +1898,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1983,34 +1960,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2035,25 +2004,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2064,21 +2027,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2086,27 +2047,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2115,21 +2069,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2155,44 +2103,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2208,26 +2141,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2241,7 +2170,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2276,11 +2205,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2336,16 +2271,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2409,13 +2334,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2426,11 +2349,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2439,21 +2362,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2467,17 +2385,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2612,14 +2532,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2629,10 +2548,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2646,13 +2565,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2678,149 +2603,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2830,13 +2627,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2850,7 +2647,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2885,11 +2682,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2945,16 +2748,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3018,13 +2811,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3035,11 +2826,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3048,21 +2839,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3076,17 +2862,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3221,14 +3009,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3238,10 +3025,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3255,13 +3042,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3287,149 +3080,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3439,13 +3104,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3459,7 +3124,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3494,11 +3159,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3555,16 +3226,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3629,12 +3290,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3645,11 +3305,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3658,23 +3318,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3688,17 +3342,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3833,14 +3489,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3850,10 +3505,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3867,13 +3522,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3899,149 +3560,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4051,13 +3584,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4072,7 +3605,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4111,11 +3644,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4181,19 +3720,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4261,13 +3790,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4279,11 +3806,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4293,22 +3820,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4321,17 +3843,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4478,14 +4002,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4496,10 +4019,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4514,13 +4037,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4547,7 +4076,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4555,142 +4084,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4700,13 +4099,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4720,7 +4119,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4755,11 +4154,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4815,16 +4220,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4888,13 +4283,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4905,11 +4298,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4918,21 +4311,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4945,17 +4333,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5090,14 +4480,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5107,10 +4496,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5124,13 +4513,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5156,149 +4551,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5308,7 +4573,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5601,17 +4866,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5619,11 +4884,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5644,15 +4909,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5678,12 +4943,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5710,14 +4974,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5726,11 +4988,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5756,17 +5018,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5793,12 +5055,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5817,7 +5079,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5864,11 +5126,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5917,16 +5185,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5961,15 +5219,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5977,29 +5233,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6074,17 +5328,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6140,7 +5396,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6149,15 +5405,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6165,7 +5420,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6174,7 +5429,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6182,7 +5437,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6207,143 +5466,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6353,14 +5485,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6377,7 +5509,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6418,11 +5550,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6470,16 +5608,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6524,14 +5652,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6540,31 +5666,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6624,17 +5746,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6707,7 +5831,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6715,7 +5839,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6723,15 +5846,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6741,14 +5864,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6773,144 +5900,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6920,14 +5920,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6944,7 +5944,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6985,11 +5985,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7038,16 +6044,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7092,14 +6088,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7108,28 +6102,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7189,17 +6182,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7273,7 +6268,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7281,7 +6276,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7289,15 +6283,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7307,14 +6301,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7339,144 +6337,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7486,7 +6357,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9286,142 +8157,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 aba21141..42c2c1ce 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 @@ -11,7 +11,6 @@ import com.withorb.api.core.JsonField import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.Params -import com.withorb.api.core.checkRequired import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import com.withorb.api.core.toImmutable @@ -27,13 +26,13 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionUpdateParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * Determines whether issued invoices for this subscription will automatically be charged with @@ -130,14 +129,9 @@ private constructor( companion object { - /** - * Returns a mutable builder for constructing an instance of [SubscriptionUpdateParams]. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - */ + @JvmStatic fun none(): SubscriptionUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SubscriptionUpdateParams]. */ @JvmStatic fun builder() = Builder() } @@ -157,7 +151,11 @@ private constructor( additionalQueryParams = subscriptionUpdateParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Sets the entire request body. @@ -418,17 +416,10 @@ private constructor( * Returns an immutable instance of [SubscriptionUpdateParams]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionId() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ fun build(): SubscriptionUpdateParams = SubscriptionUpdateParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -439,7 +430,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } 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 b5db99bb..783c38f9 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 @@ -53,13 +53,13 @@ import kotlin.jvm.optionals.getOrNull */ class SubscriptionUpdateTrialParams private constructor( - private val subscriptionId: String, + private val subscriptionId: String?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { - fun subscriptionId(): String = subscriptionId + fun subscriptionId(): Optional = Optional.ofNullable(subscriptionId) /** * The new date that the trial should end, or the literal string `immediate` to end the trial @@ -109,7 +109,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .trialEndDate() * ``` */ @@ -132,7 +131,11 @@ private constructor( additionalQueryParams = subscriptionUpdateTrialParams.additionalQueryParams.toBuilder() } - fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } + fun subscriptionId(subscriptionId: String?) = apply { this.subscriptionId = subscriptionId } + + /** Alias for calling [Builder.subscriptionId] with `subscriptionId.orElse(null)`. */ + fun subscriptionId(subscriptionId: Optional) = + subscriptionId(subscriptionId.getOrNull()) /** * Sets the entire request body. @@ -311,7 +314,6 @@ private constructor( * * The following fields are required: * ```java - * .subscriptionId() * .trialEndDate() * ``` * @@ -319,7 +321,7 @@ private constructor( */ fun build(): SubscriptionUpdateTrialParams = SubscriptionUpdateTrialParams( - checkRequired("subscriptionId", subscriptionId), + subscriptionId, body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -330,7 +332,7 @@ private constructor( fun _pathParam(index: Int): String = when (index) { - 0 -> subscriptionId + 0 -> subscriptionId ?: "" else -> "" } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt index 92ee0f7f..5925a765 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt @@ -1065,17 +1065,17 @@ private constructor( } /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofAmount(amount)`. */ - fun addDiscountInterval(amount: DiscountInterval.AmountDiscountInterval) = + fun addDiscountInterval(amount: DiscountInterval.Amount) = addDiscountInterval(DiscountInterval.ofAmount(amount)) /** * Alias for calling [addDiscountInterval] with `DiscountInterval.ofPercentage(percentage)`. */ - fun addDiscountInterval(percentage: DiscountInterval.PercentageDiscountInterval) = + fun addDiscountInterval(percentage: DiscountInterval.Percentage) = addDiscountInterval(DiscountInterval.ofPercentage(percentage)) /** Alias for calling [addDiscountInterval] with `DiscountInterval.ofUsage(usage)`. */ - fun addDiscountInterval(usage: DiscountInterval.UsageDiscountInterval) = + fun addDiscountInterval(usage: DiscountInterval.Usage) = addDiscountInterval(DiscountInterval.ofUsage(usage)) /** The date Orb stops billing for this subscription. */ @@ -1719,41 +1719,28 @@ private constructor( this.adjustment = adjustment } - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)`. - */ - fun adjustment(planPhaseUsageDiscount: Adjustment.PlanPhaseUsageDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseUsageDiscount(planPhaseUsageDiscount)) + /** Alias for calling [adjustment] with `Adjustment.ofUsageDiscount(usageDiscount)`. */ + fun adjustment(usageDiscount: Adjustment.UsageDiscount) = + adjustment(Adjustment.ofUsageDiscount(usageDiscount)) /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)`. + * Alias for calling [adjustment] with `Adjustment.ofAmountDiscount(amountDiscount)`. */ - fun adjustment(planPhaseAmountDiscount: Adjustment.PlanPhaseAmountDiscountAdjustment) = - adjustment(Adjustment.ofPlanPhaseAmountDiscount(planPhaseAmountDiscount)) + fun adjustment(amountDiscount: Adjustment.AmountDiscount) = + adjustment(Adjustment.ofAmountDiscount(amountDiscount)) /** * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)`. + * `Adjustment.ofPercentageDiscount(percentageDiscount)`. */ - fun adjustment( - planPhasePercentageDiscount: Adjustment.PlanPhasePercentageDiscountAdjustment - ) = adjustment(Adjustment.ofPlanPhasePercentageDiscount(planPhasePercentageDiscount)) + fun adjustment(percentageDiscount: Adjustment.PercentageDiscount) = + adjustment(Adjustment.ofPercentageDiscount(percentageDiscount)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)`. - */ - fun adjustment(planPhaseMinimum: Adjustment.PlanPhaseMinimumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMinimum(planPhaseMinimum)) + /** Alias for calling [adjustment] with `Adjustment.ofMinimum(minimum)`. */ + fun adjustment(minimum: Adjustment.Minimum) = adjustment(Adjustment.ofMinimum(minimum)) - /** - * Alias for calling [adjustment] with - * `Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)`. - */ - fun adjustment(planPhaseMaximum: Adjustment.PlanPhaseMaximumAdjustment) = - adjustment(Adjustment.ofPlanPhaseMaximum(planPhaseMaximum)) + /** Alias for calling [adjustment] with `Adjustment.ofMaximum(maximum)`. */ + fun adjustment(maximum: Adjustment.Maximum) = adjustment(Adjustment.ofMaximum(maximum)) /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = @@ -1902,66 +1889,56 @@ private constructor( @JsonSerialize(using = Adjustment.Serializer::class) class Adjustment private constructor( - private val planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment? = null, - private val planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment? = null, - private val planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment? = null, - private val planPhaseMinimum: PlanPhaseMinimumAdjustment? = null, - private val planPhaseMaximum: PlanPhaseMaximumAdjustment? = null, + private val usageDiscount: UsageDiscount? = null, + private val amountDiscount: AmountDiscount? = null, + private val percentageDiscount: PercentageDiscount? = null, + private val minimum: Minimum? = null, + private val maximum: Maximum? = null, private val _json: JsonValue? = null, ) { - fun planPhaseUsageDiscount(): Optional = - Optional.ofNullable(planPhaseUsageDiscount) + fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) - fun planPhaseAmountDiscount(): Optional = - Optional.ofNullable(planPhaseAmountDiscount) + fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) - fun planPhasePercentageDiscount(): Optional = - Optional.ofNullable(planPhasePercentageDiscount) + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount) - fun planPhaseMinimum(): Optional = - Optional.ofNullable(planPhaseMinimum) + fun minimum(): Optional = Optional.ofNullable(minimum) - fun planPhaseMaximum(): Optional = - Optional.ofNullable(planPhaseMaximum) + fun maximum(): Optional = Optional.ofNullable(maximum) - fun isPlanPhaseUsageDiscount(): Boolean = planPhaseUsageDiscount != null + fun isUsageDiscount(): Boolean = usageDiscount != null - fun isPlanPhaseAmountDiscount(): Boolean = planPhaseAmountDiscount != null + fun isAmountDiscount(): Boolean = amountDiscount != null - fun isPlanPhasePercentageDiscount(): Boolean = planPhasePercentageDiscount != null + fun isPercentageDiscount(): Boolean = percentageDiscount != null - fun isPlanPhaseMinimum(): Boolean = planPhaseMinimum != null + fun isMinimum(): Boolean = minimum != null - fun isPlanPhaseMaximum(): Boolean = planPhaseMaximum != null + fun isMaximum(): Boolean = maximum != null - fun asPlanPhaseUsageDiscount(): PlanPhaseUsageDiscountAdjustment = - planPhaseUsageDiscount.getOrThrow("planPhaseUsageDiscount") + fun asUsageDiscount(): UsageDiscount = usageDiscount.getOrThrow("usageDiscount") - fun asPlanPhaseAmountDiscount(): PlanPhaseAmountDiscountAdjustment = - planPhaseAmountDiscount.getOrThrow("planPhaseAmountDiscount") + fun asAmountDiscount(): AmountDiscount = amountDiscount.getOrThrow("amountDiscount") - fun asPlanPhasePercentageDiscount(): PlanPhasePercentageDiscountAdjustment = - planPhasePercentageDiscount.getOrThrow("planPhasePercentageDiscount") + fun asPercentageDiscount(): PercentageDiscount = + percentageDiscount.getOrThrow("percentageDiscount") - fun asPlanPhaseMinimum(): PlanPhaseMinimumAdjustment = - planPhaseMinimum.getOrThrow("planPhaseMinimum") + fun asMinimum(): Minimum = minimum.getOrThrow("minimum") - fun asPlanPhaseMaximum(): PlanPhaseMaximumAdjustment = - planPhaseMaximum.getOrThrow("planPhaseMaximum") + fun asMaximum(): Maximum = maximum.getOrThrow("maximum") fun _json(): Optional = Optional.ofNullable(_json) fun accept(visitor: Visitor): T = when { - planPhaseUsageDiscount != null -> - visitor.visitPlanPhaseUsageDiscount(planPhaseUsageDiscount) - planPhaseAmountDiscount != null -> - visitor.visitPlanPhaseAmountDiscount(planPhaseAmountDiscount) - planPhasePercentageDiscount != null -> - visitor.visitPlanPhasePercentageDiscount(planPhasePercentageDiscount) - planPhaseMinimum != null -> visitor.visitPlanPhaseMinimum(planPhaseMinimum) - planPhaseMaximum != null -> visitor.visitPlanPhaseMaximum(planPhaseMaximum) + 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) } @@ -1974,34 +1951,26 @@ private constructor( accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) { - planPhaseUsageDiscount.validate() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) { + usageDiscount.validate() } - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) { - planPhaseAmountDiscount.validate() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) { + amountDiscount.validate() } - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount ) { - planPhasePercentageDiscount.validate() + percentageDiscount.validate() } - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) { - planPhaseMinimum.validate() + override fun visitMinimum(minimum: Minimum) { + minimum.validate() } - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) { - planPhaseMaximum.validate() + override fun visitMaximum(maximum: Maximum) { + maximum.validate() } } ) @@ -2026,25 +1995,19 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = planPhaseUsageDiscount.validity() + override fun visitUsageDiscount(usageDiscount: UsageDiscount) = + usageDiscount.validity() - override fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = planPhaseAmountDiscount.validity() + override fun visitAmountDiscount(amountDiscount: AmountDiscount) = + amountDiscount.validity() - override fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = planPhasePercentageDiscount.validity() + override fun visitPercentageDiscount( + percentageDiscount: PercentageDiscount + ) = percentageDiscount.validity() - override fun visitPlanPhaseMinimum( - planPhaseMinimum: PlanPhaseMinimumAdjustment - ) = planPhaseMinimum.validity() + override fun visitMinimum(minimum: Minimum) = minimum.validity() - override fun visitPlanPhaseMaximum( - planPhaseMaximum: PlanPhaseMaximumAdjustment - ) = planPhaseMaximum.validity() + override fun visitMaximum(maximum: Maximum) = maximum.validity() override fun unknown(json: JsonValue?) = 0 } @@ -2055,21 +2018,19 @@ private constructor( return true } - return /* spotless:off */ other is Adjustment && planPhaseUsageDiscount == other.planPhaseUsageDiscount && planPhaseAmountDiscount == other.planPhaseAmountDiscount && planPhasePercentageDiscount == other.planPhasePercentageDiscount && planPhaseMinimum == other.planPhaseMinimum && planPhaseMaximum == other.planPhaseMaximum /* spotless:on */ + return /* spotless:off */ other is Adjustment && usageDiscount == other.usageDiscount && amountDiscount == other.amountDiscount && percentageDiscount == other.percentageDiscount && minimum == other.minimum && maximum == other.maximum /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(planPhaseUsageDiscount, planPhaseAmountDiscount, planPhasePercentageDiscount, planPhaseMinimum, planPhaseMaximum) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(usageDiscount, amountDiscount, percentageDiscount, minimum, maximum) /* spotless:on */ override fun toString(): String = when { - planPhaseUsageDiscount != null -> - "Adjustment{planPhaseUsageDiscount=$planPhaseUsageDiscount}" - planPhaseAmountDiscount != null -> - "Adjustment{planPhaseAmountDiscount=$planPhaseAmountDiscount}" - planPhasePercentageDiscount != null -> - "Adjustment{planPhasePercentageDiscount=$planPhasePercentageDiscount}" - planPhaseMinimum != null -> "Adjustment{planPhaseMinimum=$planPhaseMinimum}" - planPhaseMaximum != null -> "Adjustment{planPhaseMaximum=$planPhaseMaximum}" + 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") } @@ -2077,27 +2038,20 @@ private constructor( companion object { @JvmStatic - fun ofPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ) = Adjustment(planPhaseUsageDiscount = planPhaseUsageDiscount) + fun ofUsageDiscount(usageDiscount: UsageDiscount) = + Adjustment(usageDiscount = usageDiscount) @JvmStatic - fun ofPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ) = Adjustment(planPhaseAmountDiscount = planPhaseAmountDiscount) + fun ofAmountDiscount(amountDiscount: AmountDiscount) = + Adjustment(amountDiscount = amountDiscount) @JvmStatic - fun ofPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ) = Adjustment(planPhasePercentageDiscount = planPhasePercentageDiscount) + fun ofPercentageDiscount(percentageDiscount: PercentageDiscount) = + Adjustment(percentageDiscount = percentageDiscount) - @JvmStatic - fun ofPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment) = - Adjustment(planPhaseMinimum = planPhaseMinimum) + @JvmStatic fun ofMinimum(minimum: Minimum) = Adjustment(minimum = minimum) - @JvmStatic - fun ofPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment) = - Adjustment(planPhaseMaximum = planPhaseMaximum) + @JvmStatic fun ofMaximum(maximum: Maximum) = Adjustment(maximum = maximum) } /** @@ -2106,21 +2060,15 @@ private constructor( */ interface Visitor { - fun visitPlanPhaseUsageDiscount( - planPhaseUsageDiscount: PlanPhaseUsageDiscountAdjustment - ): T + fun visitUsageDiscount(usageDiscount: UsageDiscount): T - fun visitPlanPhaseAmountDiscount( - planPhaseAmountDiscount: PlanPhaseAmountDiscountAdjustment - ): T + fun visitAmountDiscount(amountDiscount: AmountDiscount): T - fun visitPlanPhasePercentageDiscount( - planPhasePercentageDiscount: PlanPhasePercentageDiscountAdjustment - ): T + fun visitPercentageDiscount(percentageDiscount: PercentageDiscount): T - fun visitPlanPhaseMinimum(planPhaseMinimum: PlanPhaseMinimumAdjustment): T + fun visitMinimum(minimum: Minimum): T - fun visitPlanPhaseMaximum(planPhaseMaximum: PlanPhaseMaximumAdjustment): T + fun visitMaximum(maximum: Maximum): T /** * Maps an unknown variant of [Adjustment] to a value of type [T]. @@ -2146,44 +2094,29 @@ private constructor( when (adjustmentType) { "usage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseUsageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(usageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "amount_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseAmountDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(amountDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "percentage_discount" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhasePercentageDiscount = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(percentageDiscount = it, _json = json) + } ?: Adjustment(_json = json) } "minimum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMinimum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(minimum = it, _json = json) + } ?: Adjustment(_json = json) } "maximum" -> { - return tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { Adjustment(planPhaseMaximum = it, _json = json) } - ?: Adjustment(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + Adjustment(maximum = it, _json = json) + } ?: Adjustment(_json = json) } } @@ -2199,26 +2132,22 @@ private constructor( provider: SerializerProvider, ) { when { - value.planPhaseUsageDiscount != null -> - generator.writeObject(value.planPhaseUsageDiscount) - value.planPhaseAmountDiscount != null -> - generator.writeObject(value.planPhaseAmountDiscount) - value.planPhasePercentageDiscount != null -> - generator.writeObject(value.planPhasePercentageDiscount) - value.planPhaseMinimum != null -> - generator.writeObject(value.planPhaseMinimum) - value.planPhaseMaximum != null -> - generator.writeObject(value.planPhaseMaximum) + 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") } } } - class PlanPhaseUsageDiscountAdjustment + class UsageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val planPhaseOrder: JsonField, @@ -2232,7 +2161,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -2267,11 +2196,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("usage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -2327,16 +2262,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -2400,13 +2325,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseUsageDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [UsageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2417,11 +2340,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseUsageDiscountAdjustment]. */ + /** A builder for [UsageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("usage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var planPhaseOrder: JsonField? = null @@ -2430,21 +2353,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseUsageDiscountAdjustment: PlanPhaseUsageDiscountAdjustment - ) = apply { - id = planPhaseUsageDiscountAdjustment.id - adjustmentType = planPhaseUsageDiscountAdjustment.adjustmentType + internal fun from(usageDiscount: UsageDiscount) = apply { + id = usageDiscount.id + adjustmentType = usageDiscount.adjustmentType appliesToPriceIds = - planPhaseUsageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseUsageDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseUsageDiscountAdjustment.planPhaseOrder - reason = planPhaseUsageDiscountAdjustment.reason - usageDiscount = planPhaseUsageDiscountAdjustment.usageDiscount - additionalProperties = - planPhaseUsageDiscountAdjustment.additionalProperties.toMutableMap() + usageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = usageDiscount.isInvoiceLevel + planPhaseOrder = usageDiscount.planPhaseOrder + reason = usageDiscount.reason + this.usageDiscount = usageDiscount.usageDiscount + additionalProperties = usageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -2458,17 +2376,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("usage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -2603,14 +2523,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseUsageDiscountAdjustment]. + * Returns an immutable instance of [UsageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .planPhaseOrder() @@ -2620,10 +2539,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseUsageDiscountAdjustment = - PlanPhaseUsageDiscountAdjustment( + fun build(): UsageDiscount = + UsageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -2637,13 +2556,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseUsageDiscountAdjustment = apply { + fun validate(): UsageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("usage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() planPhaseOrder() @@ -2669,149 +2594,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("usage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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_DISCOUNT = of("usage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - USAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * 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_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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_DISCOUNT -> Value.USAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to 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_DISCOUNT -> Known.USAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseUsageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UsageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -2821,13 +2618,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseUsageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "UsageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } - class PlanPhaseAmountDiscountAdjustment + class AmountDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, @@ -2841,7 +2638,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("amount_discount") @ExcludeMissing amountDiscount: JsonField = JsonMissing.of(), @@ -2876,11 +2673,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -2936,16 +2739,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [amountDiscount]. * @@ -3009,13 +2802,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseAmountDiscountAdjustment]. + * Returns a mutable builder for constructing an instance of [AmountDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3026,11 +2817,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseAmountDiscountAdjustment]. */ + /** A builder for [AmountDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("amount_discount") private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null @@ -3039,21 +2830,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhaseAmountDiscountAdjustment: PlanPhaseAmountDiscountAdjustment - ) = apply { - id = planPhaseAmountDiscountAdjustment.id - adjustmentType = planPhaseAmountDiscountAdjustment.adjustmentType - amountDiscount = planPhaseAmountDiscountAdjustment.amountDiscount + internal fun from(amountDiscount: AmountDiscount) = apply { + id = amountDiscount.id + adjustmentType = amountDiscount.adjustmentType + this.amountDiscount = amountDiscount.amountDiscount appliesToPriceIds = - planPhaseAmountDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseAmountDiscountAdjustment.isInvoiceLevel - planPhaseOrder = planPhaseAmountDiscountAdjustment.planPhaseOrder - reason = planPhaseAmountDiscountAdjustment.reason - additionalProperties = - planPhaseAmountDiscountAdjustment.additionalProperties.toMutableMap() + amountDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = amountDiscount.isInvoiceLevel + planPhaseOrder = amountDiscount.planPhaseOrder + reason = amountDiscount.reason + additionalProperties = amountDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3067,17 +2853,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("amount_discount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3212,14 +3000,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseAmountDiscountAdjustment]. + * Returns an immutable instance of [AmountDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .amountDiscount() * .appliesToPriceIds() * .isInvoiceLevel() @@ -3229,10 +3016,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseAmountDiscountAdjustment = - PlanPhaseAmountDiscountAdjustment( + fun build(): AmountDiscount = + AmountDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -3246,13 +3033,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseAmountDiscountAdjustment = apply { + fun validate(): AmountDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("amount_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } amountDiscount() appliesToPriceIds() isInvoiceLevel() @@ -3278,149 +3071,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("amount_discount")) 1 else 0 + } + (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 AMOUNT_DISCOUNT = of("amount_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - AMOUNT_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT_DISCOUNT -> Value.AMOUNT_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AMOUNT_DISCOUNT -> Known.AMOUNT_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseAmountDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is AmountDiscount && id == other.id && adjustmentType == other.adjustmentType && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -3430,13 +3095,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseAmountDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "AmountDiscount{id=$id, adjustmentType=$adjustmentType, amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhasePercentageDiscountAdjustment + class PercentageDiscount private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val percentageDiscount: JsonField, @@ -3450,7 +3115,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -3485,11 +3150,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage_discount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -3546,16 +3217,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -3620,12 +3281,11 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [PlanPhasePercentageDiscountAdjustment]. + * [PercentageDiscount]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3636,11 +3296,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhasePercentageDiscountAdjustment]. */ + /** A builder for [PercentageDiscount]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("percentage_discount") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var percentageDiscount: JsonField? = null @@ -3649,23 +3309,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from( - planPhasePercentageDiscountAdjustment: PlanPhasePercentageDiscountAdjustment - ) = apply { - id = planPhasePercentageDiscountAdjustment.id - adjustmentType = planPhasePercentageDiscountAdjustment.adjustmentType + internal fun from(percentageDiscount: PercentageDiscount) = apply { + id = percentageDiscount.id + adjustmentType = percentageDiscount.adjustmentType appliesToPriceIds = - planPhasePercentageDiscountAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhasePercentageDiscountAdjustment.isInvoiceLevel - percentageDiscount = - planPhasePercentageDiscountAdjustment.percentageDiscount - planPhaseOrder = planPhasePercentageDiscountAdjustment.planPhaseOrder - reason = planPhasePercentageDiscountAdjustment.reason + percentageDiscount.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = percentageDiscount.isInvoiceLevel + this.percentageDiscount = percentageDiscount.percentageDiscount + planPhaseOrder = percentageDiscount.planPhaseOrder + reason = percentageDiscount.reason additionalProperties = - planPhasePercentageDiscountAdjustment.additionalProperties - .toMutableMap() + percentageDiscount.additionalProperties.toMutableMap() } fun id(id: String) = id(JsonField.of(id)) @@ -3679,17 +3333,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("percentage_discount") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -3824,14 +3480,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhasePercentageDiscountAdjustment]. + * Returns an immutable instance of [PercentageDiscount]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .percentageDiscount() @@ -3841,10 +3496,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhasePercentageDiscountAdjustment = - PlanPhasePercentageDiscountAdjustment( + fun build(): PercentageDiscount = + PercentageDiscount( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -3858,13 +3513,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhasePercentageDiscountAdjustment = apply { + fun validate(): PercentageDiscount = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("percentage_discount")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() percentageDiscount() @@ -3890,149 +3551,21 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { + if (it == JsonValue.from("percentage_discount")) 1 else 0 + } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 PERCENTAGE_DISCOUNT = of("percentage_discount") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - PERCENTAGE_DISCOUNT - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE_DISCOUNT, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE_DISCOUNT -> Value.PERCENTAGE_DISCOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - PERCENTAGE_DISCOUNT -> Known.PERCENTAGE_DISCOUNT - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhasePercentageDiscountAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PercentageDiscount && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && percentageDiscount == other.percentageDiscount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4042,13 +3575,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhasePercentageDiscountAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "PercentageDiscount{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, percentageDiscount=$percentageDiscount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMinimumAdjustment + class Minimum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val itemId: JsonField, @@ -4063,7 +3596,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4102,11 +3635,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("minimum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4172,19 +3711,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [adjustmentType]. + * Returns the raw JSON value of [appliesToPriceIds]. * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - - /** - * Returns the raw JSON value of [appliesToPriceIds]. - * - * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an + * Unlike [appliesToPriceIds], this method doesn't throw if the JSON field has an * unexpected type. */ @JsonProperty("applies_to_price_ids") @@ -4252,13 +3781,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMinimumAdjustment]. + * Returns a mutable builder for constructing an instance of [Minimum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4270,11 +3797,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMinimumAdjustment]. */ + /** A builder for [Minimum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("minimum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var itemId: JsonField? = null @@ -4284,22 +3811,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMinimumAdjustment: PlanPhaseMinimumAdjustment) = - apply { - id = planPhaseMinimumAdjustment.id - adjustmentType = planPhaseMinimumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMinimumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMinimumAdjustment.isInvoiceLevel - itemId = planPhaseMinimumAdjustment.itemId - minimumAmount = planPhaseMinimumAdjustment.minimumAmount - planPhaseOrder = planPhaseMinimumAdjustment.planPhaseOrder - reason = planPhaseMinimumAdjustment.reason - additionalProperties = - planPhaseMinimumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(minimum: Minimum) = apply { + id = minimum.id + adjustmentType = minimum.adjustmentType + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = minimum.isInvoiceLevel + itemId = minimum.itemId + minimumAmount = minimum.minimumAmount + planPhaseOrder = minimum.planPhaseOrder + reason = minimum.reason + additionalProperties = minimum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4312,17 +3834,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * 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("minimum") + * ``` * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -4469,14 +3993,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMinimumAdjustment]. + * Returns an immutable instance of [Minimum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .itemId() @@ -4487,10 +4010,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMinimumAdjustment = - PlanPhaseMinimumAdjustment( + fun build(): Minimum = + Minimum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -4505,13 +4028,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMinimumAdjustment = apply { + fun validate(): Minimum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("minimum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() itemId() @@ -4538,7 +4067,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("minimum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (itemId.asKnown().isPresent) 1 else 0) + @@ -4546,142 +4075,12 @@ private constructor( (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MINIMUM = of("minimum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MINIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MINIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MINIMUM -> Value.MINIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MINIMUM -> Known.MINIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMinimumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Minimum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && itemId == other.itemId && minimumAmount == other.minimumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -4691,13 +4090,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMinimumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Minimum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, itemId=$itemId, minimumAmount=$minimumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } - class PlanPhaseMaximumAdjustment + class Maximum private constructor( private val id: JsonField, - private val adjustmentType: JsonField, + private val adjustmentType: JsonValue, private val appliesToPriceIds: JsonField>, private val isInvoiceLevel: JsonField, private val maximumAmount: JsonField, @@ -4711,7 +4110,7 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("adjustment_type") @ExcludeMissing - adjustmentType: JsonField = JsonMissing.of(), + adjustmentType: JsonValue = JsonMissing.of(), @JsonProperty("applies_to_price_ids") @ExcludeMissing appliesToPriceIds: JsonField> = JsonMissing.of(), @@ -4746,11 +4145,17 @@ private constructor( 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). + * Expected to always return the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonValue = adjustmentType /** * The price IDs that this adjustment applies to. @@ -4806,16 +4211,6 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - /** - * Returns the raw JSON value of [adjustmentType]. - * - * Unlike [adjustmentType], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adjustment_type") - @ExcludeMissing - fun _adjustmentType(): JsonField = adjustmentType - /** * Returns the raw JSON value of [appliesToPriceIds]. * @@ -4879,13 +4274,11 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PlanPhaseMaximumAdjustment]. + * Returns a mutable builder for constructing an instance of [Maximum]. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -4896,11 +4289,11 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PlanPhaseMaximumAdjustment]. */ + /** A builder for [Maximum]. */ class Builder internal constructor() { private var id: JsonField? = null - private var adjustmentType: JsonField? = null + private var adjustmentType: JsonValue = JsonValue.from("maximum") private var appliesToPriceIds: JsonField>? = null private var isInvoiceLevel: JsonField? = null private var maximumAmount: JsonField? = null @@ -4909,21 +4302,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(planPhaseMaximumAdjustment: PlanPhaseMaximumAdjustment) = - apply { - id = planPhaseMaximumAdjustment.id - adjustmentType = planPhaseMaximumAdjustment.adjustmentType - appliesToPriceIds = - planPhaseMaximumAdjustment.appliesToPriceIds.map { - it.toMutableList() - } - isInvoiceLevel = planPhaseMaximumAdjustment.isInvoiceLevel - maximumAmount = planPhaseMaximumAdjustment.maximumAmount - planPhaseOrder = planPhaseMaximumAdjustment.planPhaseOrder - reason = planPhaseMaximumAdjustment.reason - additionalProperties = - planPhaseMaximumAdjustment.additionalProperties.toMutableMap() - } + internal fun from(maximum: Maximum) = apply { + id = maximum.id + adjustmentType = maximum.adjustmentType + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } + isInvoiceLevel = maximum.isInvoiceLevel + maximumAmount = maximum.maximumAmount + planPhaseOrder = maximum.planPhaseOrder + reason = maximum.reason + additionalProperties = maximum.additionalProperties.toMutableMap() + } fun id(id: String) = id(JsonField.of(id)) @@ -4936,17 +4324,19 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } - fun adjustmentType(adjustmentType: AdjustmentType) = - adjustmentType(JsonField.of(adjustmentType)) - /** - * Sets [Builder.adjustmentType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.adjustmentType] with a well-typed - * [AdjustmentType] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to + * the following: + * ```java + * JsonValue.from("maximum") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun adjustmentType(adjustmentType: JsonField) = apply { + fun adjustmentType(adjustmentType: JsonValue) = apply { this.adjustmentType = adjustmentType } @@ -5081,14 +4471,13 @@ private constructor( } /** - * Returns an immutable instance of [PlanPhaseMaximumAdjustment]. + * Returns an immutable instance of [Maximum]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java * .id() - * .adjustmentType() * .appliesToPriceIds() * .isInvoiceLevel() * .maximumAmount() @@ -5098,10 +4487,10 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PlanPhaseMaximumAdjustment = - PlanPhaseMaximumAdjustment( + fun build(): Maximum = + Maximum( checkRequired("id", id), - checkRequired("adjustmentType", adjustmentType), + adjustmentType, checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, @@ -5115,13 +4504,19 @@ private constructor( private var validated: Boolean = false - fun validate(): PlanPhaseMaximumAdjustment = apply { + fun validate(): Maximum = apply { if (validated) { return@apply } id() - adjustmentType().validate() + _adjustmentType().let { + if (it != JsonValue.from("maximum")) { + throw OrbInvalidDataException( + "'adjustmentType' is invalid, received $it" + ) + } + } appliesToPriceIds() isInvoiceLevel() maximumAmount() @@ -5147,149 +4542,19 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + - (adjustmentType.asKnown().getOrNull()?.validity() ?: 0) + + adjustmentType.let { if (it == JsonValue.from("maximum")) 1 else 0 } + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (if (isInvoiceLevel.asKnown().isPresent) 1 else 0) + (if (maximumAmount.asKnown().isPresent) 1 else 0) + (if (planPhaseOrder.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) - class AdjustmentType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then 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 MAXIMUM = of("maximum") - - @JvmStatic fun of(value: String) = AdjustmentType(JsonField.of(value)) - } - - /** An enum containing [AdjustmentType]'s known values. */ - enum class Known { - MAXIMUM - } - - /** - * An enum containing [AdjustmentType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [AdjustmentType] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MAXIMUM, - /** - * An enum member indicating that [AdjustmentType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MAXIMUM -> Value.MAXIMUM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MAXIMUM -> Known.MAXIMUM - else -> throw OrbInvalidDataException("Unknown AdjustmentType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): AdjustmentType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is AdjustmentType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PlanPhaseMaximumAdjustment && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Maximum && id == other.id && adjustmentType == other.adjustmentType && appliesToPriceIds == other.appliesToPriceIds && isInvoiceLevel == other.isInvoiceLevel && maximumAmount == other.maximumAmount && planPhaseOrder == other.planPhaseOrder && reason == other.reason && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -5299,7 +4564,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PlanPhaseMaximumAdjustment{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" + "Maximum{id=$id, adjustmentType=$adjustmentType, appliesToPriceIds=$appliesToPriceIds, isInvoiceLevel=$isInvoiceLevel, maximumAmount=$maximumAmount, planPhaseOrder=$planPhaseOrder, reason=$reason, additionalProperties=$additionalProperties}" } } @@ -5592,17 +4857,17 @@ private constructor( @JsonSerialize(using = DiscountInterval.Serializer::class) class DiscountInterval private constructor( - private val amount: AmountDiscountInterval? = null, - private val percentage: PercentageDiscountInterval? = null, - private val usage: UsageDiscountInterval? = null, + private val amount: Amount? = null, + private val percentage: Percentage? = null, + private val usage: Usage? = null, private val _json: JsonValue? = null, ) { - fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount) - fun percentage(): Optional = Optional.ofNullable(percentage) + fun percentage(): Optional = Optional.ofNullable(percentage) - fun usage(): Optional = Optional.ofNullable(usage) + fun usage(): Optional = Optional.ofNullable(usage) fun isAmount(): Boolean = amount != null @@ -5610,11 +4875,11 @@ private constructor( fun isUsage(): Boolean = usage != null - fun asAmount(): AmountDiscountInterval = amount.getOrThrow("amount") + fun asAmount(): Amount = amount.getOrThrow("amount") - fun asPercentage(): PercentageDiscountInterval = percentage.getOrThrow("percentage") + fun asPercentage(): Percentage = percentage.getOrThrow("percentage") - fun asUsage(): UsageDiscountInterval = usage.getOrThrow("usage") + fun asUsage(): Usage = usage.getOrThrow("usage") fun _json(): Optional = Optional.ofNullable(_json) @@ -5635,15 +4900,15 @@ private constructor( accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) { + override fun visitAmount(amount: Amount) { amount.validate() } - override fun visitPercentage(percentage: PercentageDiscountInterval) { + override fun visitPercentage(percentage: Percentage) { percentage.validate() } - override fun visitUsage(usage: UsageDiscountInterval) { + override fun visitUsage(usage: Usage) { usage.validate() } } @@ -5669,12 +4934,11 @@ private constructor( internal fun validity(): Int = accept( object : Visitor { - override fun visitAmount(amount: AmountDiscountInterval) = amount.validity() + override fun visitAmount(amount: Amount) = amount.validity() - override fun visitPercentage(percentage: PercentageDiscountInterval) = - percentage.validity() + override fun visitPercentage(percentage: Percentage) = percentage.validity() - override fun visitUsage(usage: UsageDiscountInterval) = usage.validity() + override fun visitUsage(usage: Usage) = usage.validity() override fun unknown(json: JsonValue?) = 0 } @@ -5701,14 +4965,12 @@ private constructor( companion object { - @JvmStatic - fun ofAmount(amount: AmountDiscountInterval) = DiscountInterval(amount = amount) + @JvmStatic fun ofAmount(amount: Amount) = DiscountInterval(amount = amount) @JvmStatic - fun ofPercentage(percentage: PercentageDiscountInterval) = - DiscountInterval(percentage = percentage) + fun ofPercentage(percentage: Percentage) = DiscountInterval(percentage = percentage) - @JvmStatic fun ofUsage(usage: UsageDiscountInterval) = DiscountInterval(usage = usage) + @JvmStatic fun ofUsage(usage: Usage) = DiscountInterval(usage = usage) } /** @@ -5717,11 +4979,11 @@ private constructor( */ interface Visitor { - fun visitAmount(amount: AmountDiscountInterval): T + fun visitAmount(amount: Amount): T - fun visitPercentage(percentage: PercentageDiscountInterval): T + fun visitPercentage(percentage: Percentage): T - fun visitUsage(usage: UsageDiscountInterval): T + fun visitUsage(usage: Usage): T /** * Maps an unknown variant of [DiscountInterval] to a value of type [T]. @@ -5747,17 +5009,17 @@ private constructor( when (discountType) { "amount" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(amount = it, _json = json) } ?: DiscountInterval(_json = json) } "percentage" -> { - return tryDeserialize(node, jacksonTypeRef()) - ?.let { DiscountInterval(percentage = it, _json = json) } - ?: DiscountInterval(_json = json) + return tryDeserialize(node, jacksonTypeRef())?.let { + DiscountInterval(percentage = it, _json = json) + } ?: DiscountInterval(_json = json) } "usage" -> { - return tryDeserialize(node, jacksonTypeRef())?.let { + return tryDeserialize(node, jacksonTypeRef())?.let { DiscountInterval(usage = it, _json = json) } ?: DiscountInterval(_json = json) } @@ -5784,12 +5046,12 @@ private constructor( } } - class AmountDiscountInterval + class Amount private constructor( private val amountDiscount: JsonField, private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val additionalProperties: MutableMap, @@ -5808,7 +5070,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -5855,11 +5117,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("amount") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -5908,16 +5176,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -5952,15 +5210,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AmountDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Amount]. * * The following fields are required: * ```java * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` @@ -5968,29 +5224,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AmountDiscountInterval]. */ + /** A builder for [Amount]. */ class Builder internal constructor() { private var amountDiscount: JsonField? = null private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("amount") private var endDate: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { - amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = - amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(amount: Amount) = apply { + amountDiscount = amount.amountDiscount + appliesToPriceIds = amount.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = amountDiscountInterval.discountType - endDate = amountDiscountInterval.endDate - startDate = amountDiscountInterval.startDate - additionalProperties = - amountDiscountInterval.additionalProperties.toMutableMap() + amount.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = amount.discountType + endDate = amount.endDate + startDate = amount.startDate + additionalProperties = amount.additionalProperties.toMutableMap() } /** Only available if discount_type is `amount`. */ @@ -6065,17 +5319,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("amount") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6131,7 +5387,7 @@ private constructor( } /** - * Returns an immutable instance of [AmountDiscountInterval]. + * Returns an immutable instance of [Amount]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6140,15 +5396,14 @@ private constructor( * .amountDiscount() * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AmountDiscountInterval = - AmountDiscountInterval( + fun build(): Amount = + Amount( checkRequired("amountDiscount", amountDiscount), checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() @@ -6156,7 +5411,7 @@ private constructor( checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), additionalProperties.toMutableMap(), @@ -6165,7 +5420,7 @@ private constructor( private var validated: Boolean = false - fun validate(): AmountDiscountInterval = apply { + fun validate(): Amount = apply { if (validated) { return@apply } @@ -6173,7 +5428,11 @@ private constructor( amountDiscount() appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("amount")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() validated = true @@ -6198,143 +5457,16 @@ private constructor( (if (amountDiscount.asKnown().isPresent) 1 else 0) + (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("amount")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 AMOUNT = of("amount") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - AMOUNT - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AMOUNT, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AMOUNT -> Value.AMOUNT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AMOUNT -> Known.AMOUNT - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is AmountDiscountInterval && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Amount && amountDiscount == other.amountDiscount && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6344,14 +5476,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "AmountDiscountInterval{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + "Amount{amountDiscount=$amountDiscount, appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PercentageDiscountInterval + class Percentage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val percentageDiscount: JsonField, private val startDate: JsonField, @@ -6368,7 +5500,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6409,11 +5541,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -6461,16 +5599,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -6515,14 +5643,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [PercentageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Percentage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6531,31 +5657,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [PercentageDiscountInterval]. */ + /** A builder for [Percentage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("percentage") private var endDate: JsonField? = null private var percentageDiscount: JsonField? = null private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = - percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(percentage: Percentage) = apply { + appliesToPriceIds = percentage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - percentageDiscountInterval.appliesToPriceIntervalIds.map { - it.toMutableList() - } - discountType = percentageDiscountInterval.discountType - endDate = percentageDiscountInterval.endDate - percentageDiscount = percentageDiscountInterval.percentageDiscount - startDate = percentageDiscountInterval.startDate - additionalProperties = - percentageDiscountInterval.additionalProperties.toMutableMap() + percentage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = percentage.discountType + endDate = percentage.endDate + percentageDiscount = percentage.percentageDiscount + startDate = percentage.startDate + additionalProperties = percentage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -6615,17 +5737,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("percentage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -6698,7 +5822,7 @@ private constructor( } /** - * Returns an immutable instance of [PercentageDiscountInterval]. + * Returns an immutable instance of [Percentage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -6706,7 +5830,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .percentageDiscount() * .startDate() @@ -6714,15 +5837,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): PercentageDiscountInterval = - PercentageDiscountInterval( + fun build(): Percentage = + Percentage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("percentageDiscount", percentageDiscount), checkRequired("startDate", startDate), @@ -6732,14 +5855,18 @@ private constructor( private var validated: Boolean = false - fun validate(): PercentageDiscountInterval = apply { + fun validate(): Percentage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("percentage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() percentageDiscount() startDate() @@ -6764,144 +5891,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("percentage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (percentageDiscount.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 PERCENTAGE = of("percentage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - PERCENTAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PERCENTAGE, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PERCENTAGE -> Value.PERCENTAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws OrbInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PERCENTAGE -> Known.PERCENTAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is PercentageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Percentage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && percentageDiscount == other.percentageDiscount && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -6911,14 +5911,14 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "PercentageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" + "Percentage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, percentageDiscount=$percentageDiscount, startDate=$startDate, additionalProperties=$additionalProperties}" } - class UsageDiscountInterval + class Usage private constructor( private val appliesToPriceIds: JsonField>, private val appliesToPriceIntervalIds: JsonField>, - private val discountType: JsonField, + private val discountType: JsonValue, private val endDate: JsonField, private val startDate: JsonField, private val usageDiscount: JsonField, @@ -6935,7 +5935,7 @@ private constructor( appliesToPriceIntervalIds: JsonField> = JsonMissing.of(), @JsonProperty("discount_type") @ExcludeMissing - discountType: JsonField = JsonMissing.of(), + discountType: JsonValue = JsonMissing.of(), @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), @@ -6976,11 +5976,17 @@ private constructor( appliesToPriceIntervalIds.getRequired("applies_to_price_interval_ids") /** - * @throws OrbInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). + * Expected to always return the following: + * ```java + * JsonValue.from("usage") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server + * responded with an unexpected value). */ - fun discountType(): DiscountType = discountType.getRequired("discount_type") + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonValue = discountType /** * The end date of the discount interval. @@ -7029,16 +6035,6 @@ private constructor( @ExcludeMissing fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - /** - * Returns the raw JSON value of [discountType]. - * - * Unlike [discountType], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("discount_type") - @ExcludeMissing - fun _discountType(): JsonField = discountType - /** * Returns the raw JSON value of [endDate]. * @@ -7083,14 +6079,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [UsageDiscountInterval]. + * Returns a mutable builder for constructing an instance of [Usage]. * * The following fields are required: * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7099,28 +6093,27 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [UsageDiscountInterval]. */ + /** A builder for [Usage]. */ class Builder internal constructor() { private var appliesToPriceIds: JsonField>? = null private var appliesToPriceIntervalIds: JsonField>? = null - private var discountType: JsonField? = null + private var discountType: JsonValue = JsonValue.from("usage") private var endDate: JsonField? = null private var startDate: JsonField? = null private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = - usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + internal fun from(usage: Usage) = apply { + appliesToPriceIds = usage.appliesToPriceIds.map { it.toMutableList() } appliesToPriceIntervalIds = - usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } - discountType = usageDiscountInterval.discountType - endDate = usageDiscountInterval.endDate - startDate = usageDiscountInterval.startDate - usageDiscount = usageDiscountInterval.usageDiscount - additionalProperties = usageDiscountInterval.additionalProperties.toMutableMap() + usage.appliesToPriceIntervalIds.map { it.toMutableList() } + discountType = usage.discountType + endDate = usage.endDate + startDate = usage.startDate + usageDiscount = usage.usageDiscount + additionalProperties = usage.additionalProperties.toMutableMap() } /** The price ids that this discount interval applies to. */ @@ -7180,17 +6173,19 @@ private constructor( } } - fun discountType(discountType: DiscountType) = - discountType(JsonField.of(discountType)) - /** - * Sets [Builder.discountType] to an arbitrary JSON value. + * Sets the field to an arbitrary JSON value. * - * You should usually call [Builder.discountType] with a well-typed [DiscountType] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("usage") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun discountType(discountType: JsonField) = apply { + fun discountType(discountType: JsonValue) = apply { this.discountType = discountType } @@ -7264,7 +6259,7 @@ private constructor( } /** - * Returns an immutable instance of [UsageDiscountInterval]. + * Returns an immutable instance of [Usage]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -7272,7 +6267,6 @@ private constructor( * ```java * .appliesToPriceIds() * .appliesToPriceIntervalIds() - * .discountType() * .endDate() * .startDate() * .usageDiscount() @@ -7280,15 +6274,15 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): UsageDiscountInterval = - UsageDiscountInterval( + fun build(): Usage = + Usage( checkRequired("appliesToPriceIds", appliesToPriceIds).map { it.toImmutable() }, checkRequired("appliesToPriceIntervalIds", appliesToPriceIntervalIds).map { it.toImmutable() }, - checkRequired("discountType", discountType), + discountType, checkRequired("endDate", endDate), checkRequired("startDate", startDate), checkRequired("usageDiscount", usageDiscount), @@ -7298,14 +6292,18 @@ private constructor( private var validated: Boolean = false - fun validate(): UsageDiscountInterval = apply { + fun validate(): Usage = apply { if (validated) { return@apply } appliesToPriceIds() appliesToPriceIntervalIds() - discountType().validate() + _discountType().let { + if (it != JsonValue.from("usage")) { + throw OrbInvalidDataException("'discountType' is invalid, received $it") + } + } endDate() startDate() usageDiscount() @@ -7330,144 +6328,17 @@ private constructor( internal fun validity(): Int = (appliesToPriceIds.asKnown().getOrNull()?.size ?: 0) + (appliesToPriceIntervalIds.asKnown().getOrNull()?.size ?: 0) + - (discountType.asKnown().getOrNull()?.validity() ?: 0) + + discountType.let { if (it == JsonValue.from("usage")) 1 else 0 } + (if (endDate.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (usageDiscount.asKnown().isPresent) 1 else 0) - class DiscountType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then 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 = of("usage") - - @JvmStatic fun of(value: String) = DiscountType(JsonField.of(value)) - } - - /** An enum containing [DiscountType]'s known values. */ - enum class Known { - USAGE - } - - /** - * An enum containing [DiscountType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [DiscountType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may 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, - /** - * An enum member indicating that [DiscountType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead 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 -> Value.USAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to 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 -> Known.USAGE - else -> throw OrbInvalidDataException("Unknown DiscountType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and 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(): DiscountType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: OrbInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DiscountType && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UsageDiscountInterval && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Usage && appliesToPriceIds == other.appliesToPriceIds && appliesToPriceIntervalIds == other.appliesToPriceIntervalIds && discountType == other.discountType && endDate == other.endDate && startDate == other.startDate && usageDiscount == other.usageDiscount && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -7477,7 +6348,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "UsageDiscountInterval{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" + "Usage{appliesToPriceIds=$appliesToPriceIds, appliesToPriceIntervalIds=$appliesToPriceIntervalIds, discountType=$discountType, endDate=$endDate, startDate=$startDate, usageDiscount=$usageDiscount, additionalProperties=$additionalProperties}" } } @@ -9277,142 +8148,142 @@ private constructor( fun price(price: JsonField) = apply { this.price = price } /** Alias for calling [price] with `Price.ofUnit(unit)`. */ - fun price(unit: Price.UnitPrice) = price(Price.ofUnit(unit)) + fun price(unit: Price.Unit) = price(Price.ofUnit(unit)) - /** Alias for calling [price] with `Price.ofPackagePrice(packagePrice)`. */ - fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + /** 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.MatrixPrice) = price(Price.ofMatrix(matrix)) + fun price(matrix: Price.Matrix) = price(Price.ofMatrix(matrix)) /** Alias for calling [price] with `Price.ofTiered(tiered)`. */ - fun price(tiered: Price.TieredPrice) = price(Price.ofTiered(tiered)) + fun price(tiered: Price.Tiered) = price(Price.ofTiered(tiered)) /** Alias for calling [price] with `Price.ofTieredBps(tieredBps)`. */ - fun price(tieredBps: Price.TieredBpsPrice) = price(Price.ofTieredBps(tieredBps)) + fun price(tieredBps: Price.TieredBps) = price(Price.ofTieredBps(tieredBps)) /** Alias for calling [price] with `Price.ofBps(bps)`. */ - fun price(bps: Price.BpsPrice) = price(Price.ofBps(bps)) + fun price(bps: Price.Bps) = price(Price.ofBps(bps)) /** Alias for calling [price] with `Price.ofBulkBps(bulkBps)`. */ - fun price(bulkBps: Price.BulkBpsPrice) = price(Price.ofBulkBps(bulkBps)) + fun price(bulkBps: Price.BulkBps) = price(Price.ofBulkBps(bulkBps)) /** Alias for calling [price] with `Price.ofBulk(bulk)`. */ - fun price(bulk: Price.BulkPrice) = price(Price.ofBulk(bulk)) + fun price(bulk: Price.Bulk) = price(Price.ofBulk(bulk)) /** * Alias for calling [price] with `Price.ofThresholdTotalAmount(thresholdTotalAmount)`. */ - fun price(thresholdTotalAmount: Price.ThresholdTotalAmountPrice) = + fun price(thresholdTotalAmount: Price.ThresholdTotalAmount) = price(Price.ofThresholdTotalAmount(thresholdTotalAmount)) /** Alias for calling [price] with `Price.ofTieredPackage(tieredPackage)`. */ - fun price(tieredPackage: Price.TieredPackagePrice) = + fun price(tieredPackage: Price.TieredPackage) = price(Price.ofTieredPackage(tieredPackage)) /** Alias for calling [price] with `Price.ofGroupedTiered(groupedTiered)`. */ - fun price(groupedTiered: Price.GroupedTieredPrice) = + fun price(groupedTiered: Price.GroupedTiered) = price(Price.ofGroupedTiered(groupedTiered)) /** Alias for calling [price] with `Price.ofTieredWithMinimum(tieredWithMinimum)`. */ - fun price(tieredWithMinimum: Price.TieredWithMinimumPrice) = + fun price(tieredWithMinimum: Price.TieredWithMinimum) = price(Price.ofTieredWithMinimum(tieredWithMinimum)) /** * Alias for calling [price] with * `Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)`. */ - fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimumPrice) = + fun price(tieredPackageWithMinimum: Price.TieredPackageWithMinimum) = price(Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum)) /** * Alias for calling [price] with * `Price.ofPackageWithAllocation(packageWithAllocation)`. */ - fun price(packageWithAllocation: Price.PackageWithAllocationPrice) = + fun price(packageWithAllocation: Price.PackageWithAllocation) = price(Price.ofPackageWithAllocation(packageWithAllocation)) /** Alias for calling [price] with `Price.ofUnitWithPercent(unitWithPercent)`. */ - fun price(unitWithPercent: Price.UnitWithPercentPrice) = + fun price(unitWithPercent: Price.UnitWithPercent) = price(Price.ofUnitWithPercent(unitWithPercent)) /** * Alias for calling [price] with `Price.ofMatrixWithAllocation(matrixWithAllocation)`. */ - fun price(matrixWithAllocation: Price.MatrixWithAllocationPrice) = + fun price(matrixWithAllocation: Price.MatrixWithAllocation) = price(Price.ofMatrixWithAllocation(matrixWithAllocation)) /** * Alias for calling [price] with `Price.ofTieredWithProration(tieredWithProration)`. */ - fun price(tieredWithProration: Price.TieredWithProrationPrice) = + fun price(tieredWithProration: Price.TieredWithProration) = price(Price.ofTieredWithProration(tieredWithProration)) /** Alias for calling [price] with `Price.ofUnitWithProration(unitWithProration)`. */ - fun price(unitWithProration: Price.UnitWithProrationPrice) = + fun price(unitWithProration: Price.UnitWithProration) = price(Price.ofUnitWithProration(unitWithProration)) /** Alias for calling [price] with `Price.ofGroupedAllocation(groupedAllocation)`. */ - fun price(groupedAllocation: Price.GroupedAllocationPrice) = + fun price(groupedAllocation: Price.GroupedAllocation) = price(Price.ofGroupedAllocation(groupedAllocation)) /** * Alias for calling [price] with * `Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)`. */ - fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimumPrice) = + fun price(groupedWithProratedMinimum: Price.GroupedWithProratedMinimum) = price(Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum)) /** * Alias for calling [price] with * `Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)`. */ - fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimumPrice) = + fun price(groupedWithMeteredMinimum: Price.GroupedWithMeteredMinimum) = price(Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum)) /** * Alias for calling [price] with * `Price.ofMatrixWithDisplayName(matrixWithDisplayName)`. */ - fun price(matrixWithDisplayName: Price.MatrixWithDisplayNamePrice) = + fun price(matrixWithDisplayName: Price.MatrixWithDisplayName) = price(Price.ofMatrixWithDisplayName(matrixWithDisplayName)) /** Alias for calling [price] with `Price.ofBulkWithProration(bulkWithProration)`. */ - fun price(bulkWithProration: Price.BulkWithProrationPrice) = + fun price(bulkWithProration: Price.BulkWithProration) = price(Price.ofBulkWithProration(bulkWithProration)) /** * Alias for calling [price] with `Price.ofGroupedTieredPackage(groupedTieredPackage)`. */ - fun price(groupedTieredPackage: Price.GroupedTieredPackagePrice) = + fun price(groupedTieredPackage: Price.GroupedTieredPackage) = price(Price.ofGroupedTieredPackage(groupedTieredPackage)) /** * Alias for calling [price] with * `Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)`. */ - fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackagePrice) = + fun price(maxGroupTieredPackage: Price.MaxGroupTieredPackage) = price(Price.ofMaxGroupTieredPackage(maxGroupTieredPackage)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)`. */ - fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricingPrice) = + fun price(scalableMatrixWithUnitPricing: Price.ScalableMatrixWithUnitPricing) = price(Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing)) /** * Alias for calling [price] with * `Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)`. */ - fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricingPrice) = + fun price(scalableMatrixWithTieredPricing: Price.ScalableMatrixWithTieredPricing) = price(Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing)) /** * Alias for calling [price] with * `Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)`. */ - fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulkPrice) = + fun price(cumulativeGroupedBulk: Price.CumulativeGroupedBulk) = price(Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk)) /** 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 c2b19190..62cc679b 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 @@ -25,8 +25,22 @@ interface AlertServiceAsync { fun withRawResponse(): WithRawResponse /** This endpoint retrieves an alert by its ID. */ - fun retrieve(params: AlertRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) + fun retrieve(alertId: String): CompletableFuture = + retrieve(alertId, AlertRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + alertId: String, + params: AlertRetrieveParams = AlertRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve( + alertId: String, + params: AlertRetrieveParams = AlertRetrieveParams.none(), + ): CompletableFuture = retrieve(alertId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -34,7 +48,30 @@ interface AlertServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve(params: AlertRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(alertId: String, requestOptions: RequestOptions): CompletableFuture = + retrieve(alertId, AlertRetrieveParams.none(), requestOptions) + /** This endpoint updates the thresholds of an alert. */ + fun update(alertConfigurationId: String, params: AlertUpdateParams): CompletableFuture = + update(alertConfigurationId, params, RequestOptions.none()) + + /** @see [update] */ + fun update( + alertConfigurationId: String, + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [update] */ fun update(params: AlertUpdateParams): CompletableFuture = update(params, RequestOptions.none()) @@ -80,6 +117,20 @@ interface AlertServiceAsync { * `credit_balance_dropped` alerts require a list of thresholds to be provided while * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. */ + fun createForCustomer( + customerId: String, + params: AlertCreateForCustomerParams, + ): CompletableFuture = createForCustomer(customerId, params, RequestOptions.none()) + + /** @see [createForCustomer] */ + fun createForCustomer( + customerId: String, + params: AlertCreateForCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + createForCustomer(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [createForCustomer] */ fun createForCustomer(params: AlertCreateForCustomerParams): CompletableFuture = createForCustomer(params, RequestOptions.none()) @@ -97,6 +148,24 @@ interface AlertServiceAsync { * `credit_balance_dropped` alerts require a list of thresholds to be provided while * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. */ + fun createForExternalCustomer( + externalCustomerId: String, + params: AlertCreateForExternalCustomerParams, + ): CompletableFuture = + createForExternalCustomer(externalCustomerId, params, RequestOptions.none()) + + /** @see [createForExternalCustomer] */ + fun createForExternalCustomer( + externalCustomerId: String, + params: AlertCreateForExternalCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + createForExternalCustomer( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createForExternalCustomer] */ fun createForExternalCustomer( params: AlertCreateForExternalCustomerParams ): CompletableFuture = createForExternalCustomer(params, RequestOptions.none()) @@ -119,6 +188,24 @@ interface AlertServiceAsync { * per metric that is a part of the subscription. Alerts are triggered based on usage or cost * conditions met during the current billing cycle. */ + fun createForSubscription( + subscriptionId: String, + params: AlertCreateForSubscriptionParams, + ): CompletableFuture = + createForSubscription(subscriptionId, params, RequestOptions.none()) + + /** @see [createForSubscription] */ + fun createForSubscription( + subscriptionId: String, + params: AlertCreateForSubscriptionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + createForSubscription( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [createForSubscription] */ fun createForSubscription(params: AlertCreateForSubscriptionParams): CompletableFuture = createForSubscription(params, RequestOptions.none()) @@ -133,8 +220,25 @@ interface AlertServiceAsync { * subscription, you must include the `subscription_id`. The `subscription_id` is not required * for customer or subscription level alerts. */ - fun disable(params: AlertDisableParams): CompletableFuture = - disable(params, RequestOptions.none()) + fun disable(alertConfigurationId: String): CompletableFuture = + disable(alertConfigurationId, AlertDisableParams.none()) + + /** @see [disable] */ + fun disable( + alertConfigurationId: String, + params: AlertDisableParams = AlertDisableParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + disable( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [disable] */ + fun disable( + alertConfigurationId: String, + params: AlertDisableParams = AlertDisableParams.none(), + ): CompletableFuture = disable(alertConfigurationId, params, RequestOptions.none()) /** @see [disable] */ fun disable( @@ -142,13 +246,41 @@ interface AlertServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [disable] */ + fun disable(params: AlertDisableParams): CompletableFuture = + disable(params, RequestOptions.none()) + + /** @see [disable] */ + fun disable( + alertConfigurationId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + disable(alertConfigurationId, AlertDisableParams.none(), requestOptions) + /** * This endpoint allows you to enable an alert. To enable a plan-level alert for a specific * subscription, you must include the `subscription_id`. The `subscription_id` is not required * for customer or subscription level alerts. */ - fun enable(params: AlertEnableParams): CompletableFuture = - enable(params, RequestOptions.none()) + fun enable(alertConfigurationId: String): CompletableFuture = + enable(alertConfigurationId, AlertEnableParams.none()) + + /** @see [enable] */ + fun enable( + alertConfigurationId: String, + params: AlertEnableParams = AlertEnableParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + enable( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [enable] */ + fun enable( + alertConfigurationId: String, + params: AlertEnableParams = AlertEnableParams.none(), + ): CompletableFuture = enable(alertConfigurationId, params, RequestOptions.none()) /** @see [enable] */ fun enable( @@ -156,6 +288,17 @@ interface AlertServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [enable] */ + fun enable(params: AlertEnableParams): CompletableFuture = + enable(params, RequestOptions.none()) + + /** @see [enable] */ + fun enable( + alertConfigurationId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + enable(alertConfigurationId, AlertEnableParams.none(), requestOptions) + /** A view of [AlertServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -164,8 +307,25 @@ interface AlertServiceAsync { * [AlertServiceAsync.retrieve]. */ @MustBeClosed - fun retrieve(params: AlertRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) + fun retrieve(alertId: String): CompletableFuture> = + retrieve(alertId, AlertRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + alertId: String, + params: AlertRetrieveParams = AlertRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + alertId: String, + params: AlertRetrieveParams = AlertRetrieveParams.none(), + ): CompletableFuture> = + retrieve(alertId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -174,11 +334,44 @@ interface AlertServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: AlertRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + alertId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(alertId, AlertRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /alerts/{alert_configuration_id}`, but is otherwise * the same as [AlertServiceAsync.update]. */ @MustBeClosed + fun update( + alertConfigurationId: String, + params: AlertUpdateParams, + ): CompletableFuture> = + update(alertConfigurationId, params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + alertConfigurationId: String, + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [update] */ + @MustBeClosed fun update(params: AlertUpdateParams): CompletableFuture> = update(params, RequestOptions.none()) @@ -223,6 +416,23 @@ interface AlertServiceAsync { * otherwise the same as [AlertServiceAsync.createForCustomer]. */ @MustBeClosed + fun createForCustomer( + customerId: String, + params: AlertCreateForCustomerParams, + ): CompletableFuture> = + createForCustomer(customerId, params, RequestOptions.none()) + + /** @see [createForCustomer] */ + @MustBeClosed + fun createForCustomer( + customerId: String, + params: AlertCreateForCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + createForCustomer(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [createForCustomer] */ + @MustBeClosed fun createForCustomer( params: AlertCreateForCustomerParams ): CompletableFuture> = @@ -241,6 +451,26 @@ interface AlertServiceAsync { * [AlertServiceAsync.createForExternalCustomer]. */ @MustBeClosed + fun createForExternalCustomer( + externalCustomerId: String, + params: AlertCreateForExternalCustomerParams, + ): CompletableFuture> = + createForExternalCustomer(externalCustomerId, params, RequestOptions.none()) + + /** @see [createForExternalCustomer] */ + @MustBeClosed + fun createForExternalCustomer( + externalCustomerId: String, + params: AlertCreateForExternalCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + createForExternalCustomer( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createForExternalCustomer] */ + @MustBeClosed fun createForExternalCustomer( params: AlertCreateForExternalCustomerParams ): CompletableFuture> = @@ -258,6 +488,26 @@ interface AlertServiceAsync { * otherwise the same as [AlertServiceAsync.createForSubscription]. */ @MustBeClosed + fun createForSubscription( + subscriptionId: String, + params: AlertCreateForSubscriptionParams, + ): CompletableFuture> = + createForSubscription(subscriptionId, params, RequestOptions.none()) + + /** @see [createForSubscription] */ + @MustBeClosed + fun createForSubscription( + subscriptionId: String, + params: AlertCreateForSubscriptionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + createForSubscription( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [createForSubscription] */ + @MustBeClosed fun createForSubscription( params: AlertCreateForSubscriptionParams ): CompletableFuture> = @@ -275,8 +525,28 @@ interface AlertServiceAsync { * otherwise the same as [AlertServiceAsync.disable]. */ @MustBeClosed - fun disable(params: AlertDisableParams): CompletableFuture> = - disable(params, RequestOptions.none()) + fun disable(alertConfigurationId: String): CompletableFuture> = + disable(alertConfigurationId, AlertDisableParams.none()) + + /** @see [disable] */ + @MustBeClosed + fun disable( + alertConfigurationId: String, + params: AlertDisableParams = AlertDisableParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + disable( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [disable] */ + @MustBeClosed + fun disable( + alertConfigurationId: String, + params: AlertDisableParams = AlertDisableParams.none(), + ): CompletableFuture> = + disable(alertConfigurationId, params, RequestOptions.none()) /** @see [disable] */ @MustBeClosed @@ -285,13 +555,46 @@ interface AlertServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [disable] */ + @MustBeClosed + fun disable(params: AlertDisableParams): CompletableFuture> = + disable(params, RequestOptions.none()) + + /** @see [disable] */ + @MustBeClosed + fun disable( + alertConfigurationId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + disable(alertConfigurationId, AlertDisableParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/enable`, but is * otherwise the same as [AlertServiceAsync.enable]. */ @MustBeClosed - fun enable(params: AlertEnableParams): CompletableFuture> = - enable(params, RequestOptions.none()) + fun enable(alertConfigurationId: String): CompletableFuture> = + enable(alertConfigurationId, AlertEnableParams.none()) + + /** @see [enable] */ + @MustBeClosed + fun enable( + alertConfigurationId: String, + params: AlertEnableParams = AlertEnableParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + enable( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [enable] */ + @MustBeClosed + fun enable( + alertConfigurationId: String, + params: AlertEnableParams = AlertEnableParams.none(), + ): CompletableFuture> = + enable(alertConfigurationId, params, RequestOptions.none()) /** @see [enable] */ @MustBeClosed @@ -299,5 +602,18 @@ interface AlertServiceAsync { params: AlertEnableParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [enable] */ + @MustBeClosed + fun enable(params: AlertEnableParams): CompletableFuture> = + enable(params, RequestOptions.none()) + + /** @see [enable] */ + @MustBeClosed + fun enable( + alertConfigurationId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + enable(alertConfigurationId, AlertEnableParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt index 3a07f60d..b54ccfc7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/AlertServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -27,6 +28,7 @@ import com.withorb.api.models.AlertListParams import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class AlertServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AlertServiceAsync { @@ -105,6 +107,9 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AlertRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertId", params.alertId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -134,6 +139,9 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AlertUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertConfigurationId", params.alertConfigurationId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -186,6 +194,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie .let { AlertListPageAsync.builder() .service(AlertServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -201,6 +210,9 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AlertCreateForCustomerParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -231,6 +243,9 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AlertCreateForExternalCustomerParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -261,6 +276,9 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AlertCreateForSubscriptionParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -291,6 +309,9 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AlertDisableParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertConfigurationId", params.alertConfigurationId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -321,6 +342,9 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie params: AlertEnableParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertConfigurationId", params.alertConfigurationId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt index d3cbe42e..0fceafb7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsync.kt @@ -66,8 +66,22 @@ interface CouponServiceAsync { * will be hidden from lists of active coupons. Additionally, once a coupon is archived, its * redemption code can be reused for a different coupon. */ - fun archive(params: CouponArchiveParams): CompletableFuture = - archive(params, RequestOptions.none()) + fun archive(couponId: String): CompletableFuture = + archive(couponId, CouponArchiveParams.none()) + + /** @see [archive] */ + fun archive( + couponId: String, + params: CouponArchiveParams = CouponArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + archive(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [archive] */ + fun archive( + couponId: String, + params: CouponArchiveParams = CouponArchiveParams.none(), + ): CompletableFuture = archive(couponId, params, RequestOptions.none()) /** @see [archive] */ fun archive( @@ -75,12 +89,34 @@ interface CouponServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [archive] */ + fun archive(params: CouponArchiveParams): CompletableFuture = + archive(params, RequestOptions.none()) + + /** @see [archive] */ + fun archive(couponId: String, requestOptions: RequestOptions): CompletableFuture = + archive(couponId, CouponArchiveParams.none(), requestOptions) + /** * This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption code, use * the [List coupons](list-coupons) endpoint with the redemption_code parameter. */ - fun fetch(params: CouponFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(couponId: String): CompletableFuture = + fetch(couponId, CouponFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + couponId: String, + params: CouponFetchParams = CouponFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetch(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + couponId: String, + params: CouponFetchParams = CouponFetchParams.none(), + ): CompletableFuture = fetch(couponId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -88,6 +124,14 @@ interface CouponServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: CouponFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(couponId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(couponId, CouponFetchParams.none(), requestOptions) + /** * A view of [CouponServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -144,8 +188,25 @@ interface CouponServiceAsync { * same as [CouponServiceAsync.archive]. */ @MustBeClosed - fun archive(params: CouponArchiveParams): CompletableFuture> = - archive(params, RequestOptions.none()) + fun archive(couponId: String): CompletableFuture> = + archive(couponId, CouponArchiveParams.none()) + + /** @see [archive] */ + @MustBeClosed + fun archive( + couponId: String, + params: CouponArchiveParams = CouponArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + archive(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [archive] */ + @MustBeClosed + fun archive( + couponId: String, + params: CouponArchiveParams = CouponArchiveParams.none(), + ): CompletableFuture> = + archive(couponId, params, RequestOptions.none()) /** @see [archive] */ @MustBeClosed @@ -154,13 +215,43 @@ interface CouponServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [archive] */ + @MustBeClosed + fun archive(params: CouponArchiveParams): CompletableFuture> = + archive(params, RequestOptions.none()) + + /** @see [archive] */ + @MustBeClosed + fun archive( + couponId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + archive(couponId, CouponArchiveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /coupons/{coupon_id}`, but is otherwise the same as * [CouponServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: CouponFetchParams): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(couponId: String): CompletableFuture> = + fetch(couponId, CouponFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + couponId: String, + params: CouponFetchParams = CouponFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + couponId: String, + params: CouponFetchParams = CouponFetchParams.none(), + ): CompletableFuture> = + fetch(couponId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -168,5 +259,18 @@ interface CouponServiceAsync { params: CouponFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: CouponFetchParams): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + couponId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(couponId, CouponFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt index 38a83bca..e9232e59 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CouponServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import com.withorb.api.models.CouponListParams import com.withorb.api.services.async.coupons.SubscriptionServiceAsync import com.withorb.api.services.async.coupons.SubscriptionServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CouponServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CouponServiceAsync { @@ -139,6 +141,7 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli .let { CouponListPageAsync.builder() .service(CouponServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -154,6 +157,9 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CouponArchiveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("couponId", params.couponId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -184,6 +190,9 @@ class CouponServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CouponFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("couponId", params.couponId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt index dbf8afee..d3ad060b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsync.kt @@ -55,8 +55,22 @@ interface CreditNoteServiceAsync { * This endpoint is used to fetch a single [`Credit Note`](/invoicing/credit-notes) given an * identifier. */ - fun fetch(params: CreditNoteFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(creditNoteId: String): CompletableFuture = + fetch(creditNoteId, CreditNoteFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + creditNoteId: String, + params: CreditNoteFetchParams = CreditNoteFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetch(params.toBuilder().creditNoteId(creditNoteId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + creditNoteId: String, + params: CreditNoteFetchParams = CreditNoteFetchParams.none(), + ): CompletableFuture = fetch(creditNoteId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -64,6 +78,14 @@ interface CreditNoteServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: CreditNoteFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(creditNoteId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(creditNoteId, CreditNoteFetchParams.none(), requestOptions) + /** * A view of [CreditNoteServiceAsync] that provides access to raw HTTP responses for each * method. @@ -119,8 +141,25 @@ interface CreditNoteServiceAsync { * the same as [CreditNoteServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: CreditNoteFetchParams): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(creditNoteId: String): CompletableFuture> = + fetch(creditNoteId, CreditNoteFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + creditNoteId: String, + params: CreditNoteFetchParams = CreditNoteFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().creditNoteId(creditNoteId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + creditNoteId: String, + params: CreditNoteFetchParams = CreditNoteFetchParams.none(), + ): CompletableFuture> = + fetch(creditNoteId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -128,5 +167,18 @@ interface CreditNoteServiceAsync { params: CreditNoteFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: CreditNoteFetchParams): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + creditNoteId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(creditNoteId, CreditNoteFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt index 1c25b2ee..c7261198 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -22,6 +23,7 @@ import com.withorb.api.models.CreditNoteListPageAsync import com.withorb.api.models.CreditNoteListPageResponse import com.withorb.api.models.CreditNoteListParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CreditNoteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteServiceAsync { @@ -117,6 +119,7 @@ class CreditNoteServiceAsyncImpl internal constructor(private val clientOptions: .let { CreditNoteListPageAsync.builder() .service(CreditNoteServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -132,6 +135,9 @@ class CreditNoteServiceAsyncImpl internal constructor(private val clientOptions: params: CreditNoteFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("creditNoteId", params.creditNoteId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 0b1495b1..629d4973 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 @@ -63,8 +63,22 @@ interface CustomerServiceAsync { * `billing_address`, and `additional_emails` of an existing customer. Other fields on a * customer are currently immutable. */ - fun update(params: CustomerUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(customerId: String): CompletableFuture = + update(customerId, CustomerUpdateParams.none()) + + /** @see [update] */ + fun update( + customerId: String, + params: CustomerUpdateParams = CustomerUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [update] */ + fun update( + customerId: String, + params: CustomerUpdateParams = CustomerUpdateParams.none(), + ): CompletableFuture = update(customerId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -72,6 +86,14 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: CustomerUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(customerId: String, requestOptions: RequestOptions): CompletableFuture = + update(customerId, CustomerUpdateParams.none(), requestOptions) + /** * This endpoint returns a list of all customers for an account. The list of customers is * ordered starting from the most recently created customer. This endpoint follows Orb's @@ -111,8 +133,22 @@ interface CustomerServiceAsync { * * On successful processing, this returns an empty dictionary (`{}`) in the API. */ - fun delete(params: CustomerDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(customerId: String): CompletableFuture = + delete(customerId, CustomerDeleteParams.none()) + + /** @see [delete] */ + fun delete( + customerId: String, + params: CustomerDeleteParams = CustomerDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [delete] */ + fun delete( + customerId: String, + params: CustomerDeleteParams = CustomerDeleteParams.none(), + ): CompletableFuture = delete(customerId, params, RequestOptions.none()) /** @see [delete] */ fun delete( @@ -120,6 +156,14 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + fun delete(params: CustomerDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(customerId: String, requestOptions: RequestOptions): CompletableFuture = + delete(customerId, CustomerDeleteParams.none(), requestOptions) + /** * This endpoint is used to fetch customer details given an identifier. If the `Customer` is in * the process of being deleted, only the properties `id` and `deleted: true` will be returned. @@ -127,8 +171,22 @@ interface CustomerServiceAsync { * See the [Customer resource](/core-concepts#customer) for a full discussion of the Customer * model. */ - fun fetch(params: CustomerFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(customerId: String): CompletableFuture = + fetch(customerId, CustomerFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + customerId: String, + params: CustomerFetchParams = CustomerFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetch(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + customerId: String, + params: CustomerFetchParams = CustomerFetchParams.none(), + ): CompletableFuture = fetch(customerId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -136,6 +194,14 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: CustomerFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(customerId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(customerId, CustomerFetchParams.none(), requestOptions) + /** * This endpoint is used to fetch customer details given an `external_customer_id` (see * [Customer ID Aliases](/events-and-metrics/customer-aliases)). @@ -143,8 +209,26 @@ interface CustomerServiceAsync { * Note that the resource and semantics of this endpoint exactly mirror * [Get Customer](fetch-customer). */ - fun fetchByExternalId(params: CustomerFetchByExternalIdParams): CompletableFuture = - fetchByExternalId(params, RequestOptions.none()) + fun fetchByExternalId(externalCustomerId: String): CompletableFuture = + fetchByExternalId(externalCustomerId, CustomerFetchByExternalIdParams.none()) + + /** @see [fetchByExternalId] */ + fun fetchByExternalId( + externalCustomerId: String, + params: CustomerFetchByExternalIdParams = CustomerFetchByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetchByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [fetchByExternalId] */ + fun fetchByExternalId( + externalCustomerId: String, + params: CustomerFetchByExternalIdParams = CustomerFetchByExternalIdParams.none(), + ): CompletableFuture = + fetchByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [fetchByExternalId] */ fun fetchByExternalId( @@ -152,6 +236,21 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetchByExternalId] */ + fun fetchByExternalId(params: CustomerFetchByExternalIdParams): CompletableFuture = + fetchByExternalId(params, RequestOptions.none()) + + /** @see [fetchByExternalId] */ + fun fetchByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + fetchByExternalId( + externalCustomerId, + CustomerFetchByExternalIdParams.none(), + requestOptions, + ) + /** * Sync Orb's payment methods for the customer with their gateway. * @@ -160,9 +259,31 @@ interface CustomerServiceAsync { * * **Note**: This functionality is currently only available for Stripe. */ + fun syncPaymentMethodsFromGateway(customerId: String): CompletableFuture = + syncPaymentMethodsFromGateway( + customerId, + CustomerSyncPaymentMethodsFromGatewayParams.none(), + ) + + /** @see [syncPaymentMethodsFromGateway] */ fun syncPaymentMethodsFromGateway( - params: CustomerSyncPaymentMethodsFromGatewayParams - ): CompletableFuture = syncPaymentMethodsFromGateway(params, RequestOptions.none()) + customerId: String, + params: CustomerSyncPaymentMethodsFromGatewayParams = + CustomerSyncPaymentMethodsFromGatewayParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + syncPaymentMethodsFromGateway( + params.toBuilder().customerId(customerId).build(), + requestOptions, + ) + + /** @see [syncPaymentMethodsFromGateway] */ + fun syncPaymentMethodsFromGateway( + customerId: String, + params: CustomerSyncPaymentMethodsFromGatewayParams = + CustomerSyncPaymentMethodsFromGatewayParams.none(), + ): CompletableFuture = + syncPaymentMethodsFromGateway(customerId, params, RequestOptions.none()) /** @see [syncPaymentMethodsFromGateway] */ fun syncPaymentMethodsFromGateway( @@ -170,6 +291,22 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [syncPaymentMethodsFromGateway] */ + fun syncPaymentMethodsFromGateway( + params: CustomerSyncPaymentMethodsFromGatewayParams + ): CompletableFuture = syncPaymentMethodsFromGateway(params, RequestOptions.none()) + + /** @see [syncPaymentMethodsFromGateway] */ + fun syncPaymentMethodsFromGateway( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + syncPaymentMethodsFromGateway( + customerId, + CustomerSyncPaymentMethodsFromGatewayParams.none(), + requestOptions, + ) + /** * Sync Orb's payment methods for the customer with their gateway. * @@ -179,9 +316,36 @@ interface CustomerServiceAsync { * **Note**: This functionality is currently only available for Stripe. */ fun syncPaymentMethodsFromGatewayByExternalCustomerId( - params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams + externalCustomerId: String ): CompletableFuture = - syncPaymentMethodsFromGatewayByExternalCustomerId(params, RequestOptions.none()) + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + ) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + syncPaymentMethodsFromGatewayByExternalCustomerId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + ): CompletableFuture = + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + params, + RequestOptions.none(), + ) /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ fun syncPaymentMethodsFromGatewayByExternalCustomerId( @@ -189,13 +353,44 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams + ): CompletableFuture = + syncPaymentMethodsFromGatewayByExternalCustomerId(params, RequestOptions.none()) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + requestOptions, + ) + /** * This endpoint is used to update customer details given an `external_customer_id` (see * [Customer ID Aliases](/events-and-metrics/customer-aliases)). Note that the resource and * semantics of this endpoint exactly mirror [Update Customer](update-customer). */ - fun updateByExternalId(params: CustomerUpdateByExternalIdParams): CompletableFuture = - updateByExternalId(params, RequestOptions.none()) + fun updateByExternalId(id: String): CompletableFuture = + updateByExternalId(id, CustomerUpdateByExternalIdParams.none()) + + /** @see [updateByExternalId] */ + fun updateByExternalId( + id: String, + params: CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + updateByExternalId(params.toBuilder().id(id).build(), requestOptions) + + /** @see [updateByExternalId] */ + fun updateByExternalId( + id: String, + params: CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams.none(), + ): CompletableFuture = updateByExternalId(id, params, RequestOptions.none()) /** @see [updateByExternalId] */ fun updateByExternalId( @@ -203,6 +398,17 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [updateByExternalId] */ + fun updateByExternalId(params: CustomerUpdateByExternalIdParams): CompletableFuture = + updateByExternalId(params, RequestOptions.none()) + + /** @see [updateByExternalId] */ + fun updateByExternalId( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + updateByExternalId(id, CustomerUpdateByExternalIdParams.none(), requestOptions) + /** * A view of [CustomerServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -234,8 +440,25 @@ interface CustomerServiceAsync { * as [CustomerServiceAsync.update]. */ @MustBeClosed - fun update(params: CustomerUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + fun update(customerId: String): CompletableFuture> = + update(customerId, CustomerUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + customerId: String, + params: CustomerUpdateParams = CustomerUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + customerId: String, + params: CustomerUpdateParams = CustomerUpdateParams.none(), + ): CompletableFuture> = + update(customerId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -244,6 +467,19 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update(params: CustomerUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(customerId, CustomerUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /customers`, but is otherwise the same as * [CustomerServiceAsync.list]. @@ -278,8 +514,24 @@ interface CustomerServiceAsync { * same as [CustomerServiceAsync.delete]. */ @MustBeClosed - fun delete(params: CustomerDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) + fun delete(customerId: String): CompletableFuture = + delete(customerId, CustomerDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + customerId: String, + params: CustomerDeleteParams = CustomerDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + customerId: String, + params: CustomerDeleteParams = CustomerDeleteParams.none(), + ): CompletableFuture = delete(customerId, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -288,13 +540,43 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [delete] */ + @MustBeClosed + fun delete(params: CustomerDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(customerId, CustomerDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /customers/{customer_id}`, but is otherwise the same * as [CustomerServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: CustomerFetchParams): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(customerId: String): CompletableFuture> = + fetch(customerId, CustomerFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + customerId: String, + params: CustomerFetchParams = CustomerFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + customerId: String, + params: CustomerFetchParams = CustomerFetchParams.none(), + ): CompletableFuture> = + fetch(customerId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -303,6 +585,19 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: CustomerFetchParams): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(customerId, CustomerFetchParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get * /customers/external_customer_id/{external_customer_id}`, but is otherwise the same as @@ -310,9 +605,29 @@ interface CustomerServiceAsync { */ @MustBeClosed fun fetchByExternalId( - params: CustomerFetchByExternalIdParams + externalCustomerId: String ): CompletableFuture> = - fetchByExternalId(params, RequestOptions.none()) + fetchByExternalId(externalCustomerId, CustomerFetchByExternalIdParams.none()) + + /** @see [fetchByExternalId] */ + @MustBeClosed + fun fetchByExternalId( + externalCustomerId: String, + params: CustomerFetchByExternalIdParams = CustomerFetchByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetchByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [fetchByExternalId] */ + @MustBeClosed + fun fetchByExternalId( + externalCustomerId: String, + params: CustomerFetchByExternalIdParams = CustomerFetchByExternalIdParams.none(), + ): CompletableFuture> = + fetchByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [fetchByExternalId] */ @MustBeClosed @@ -321,16 +636,58 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [fetchByExternalId] */ + @MustBeClosed + fun fetchByExternalId( + params: CustomerFetchByExternalIdParams + ): CompletableFuture> = + fetchByExternalId(params, RequestOptions.none()) + + /** @see [fetchByExternalId] */ + @MustBeClosed + fun fetchByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetchByExternalId( + externalCustomerId, + CustomerFetchByExternalIdParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `post * /customers/{customer_id}/sync_payment_methods_from_gateway`, but is otherwise the same as * [CustomerServiceAsync.syncPaymentMethodsFromGateway]. */ @MustBeClosed + fun syncPaymentMethodsFromGateway(customerId: String): CompletableFuture = + syncPaymentMethodsFromGateway( + customerId, + CustomerSyncPaymentMethodsFromGatewayParams.none(), + ) + + /** @see [syncPaymentMethodsFromGateway] */ + @MustBeClosed fun syncPaymentMethodsFromGateway( - params: CustomerSyncPaymentMethodsFromGatewayParams + customerId: String, + params: CustomerSyncPaymentMethodsFromGatewayParams = + CustomerSyncPaymentMethodsFromGatewayParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = - syncPaymentMethodsFromGateway(params, RequestOptions.none()) + syncPaymentMethodsFromGateway( + params.toBuilder().customerId(customerId).build(), + requestOptions, + ) + + /** @see [syncPaymentMethodsFromGateway] */ + @MustBeClosed + fun syncPaymentMethodsFromGateway( + customerId: String, + params: CustomerSyncPaymentMethodsFromGatewayParams = + CustomerSyncPaymentMethodsFromGatewayParams.none(), + ): CompletableFuture = + syncPaymentMethodsFromGateway(customerId, params, RequestOptions.none()) /** @see [syncPaymentMethodsFromGateway] */ @MustBeClosed @@ -339,6 +696,25 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [syncPaymentMethodsFromGateway] */ + @MustBeClosed + fun syncPaymentMethodsFromGateway( + params: CustomerSyncPaymentMethodsFromGatewayParams + ): CompletableFuture = + syncPaymentMethodsFromGateway(params, RequestOptions.none()) + + /** @see [syncPaymentMethodsFromGateway] */ + @MustBeClosed + fun syncPaymentMethodsFromGateway( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + syncPaymentMethodsFromGateway( + customerId, + CustomerSyncPaymentMethodsFromGatewayParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `post * /customers/external_customer_id/{external_customer_id}/sync_payment_methods_from_gateway`, @@ -347,9 +723,38 @@ interface CustomerServiceAsync { */ @MustBeClosed fun syncPaymentMethodsFromGatewayByExternalCustomerId( - params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams + externalCustomerId: String ): CompletableFuture = - syncPaymentMethodsFromGatewayByExternalCustomerId(params, RequestOptions.none()) + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + ) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + syncPaymentMethodsFromGatewayByExternalCustomerId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + ): CompletableFuture = + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + params, + RequestOptions.none(), + ) /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ @MustBeClosed @@ -358,16 +763,50 @@ interface CustomerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams + ): CompletableFuture = + syncPaymentMethodsFromGatewayByExternalCustomerId(params, RequestOptions.none()) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `put * /customers/external_customer_id/{external_customer_id}`, but is otherwise the same as * [CustomerServiceAsync.updateByExternalId]. */ @MustBeClosed + fun updateByExternalId(id: String): CompletableFuture> = + updateByExternalId(id, CustomerUpdateByExternalIdParams.none()) + + /** @see [updateByExternalId] */ + @MustBeClosed fun updateByExternalId( - params: CustomerUpdateByExternalIdParams + id: String, + params: CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - updateByExternalId(params, RequestOptions.none()) + updateByExternalId(params.toBuilder().id(id).build(), requestOptions) + + /** @see [updateByExternalId] */ + @MustBeClosed + fun updateByExternalId( + id: String, + params: CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams.none(), + ): CompletableFuture> = + updateByExternalId(id, params, RequestOptions.none()) /** @see [updateByExternalId] */ @MustBeClosed @@ -375,5 +814,20 @@ interface CustomerServiceAsync { params: CustomerUpdateByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [updateByExternalId] */ + @MustBeClosed + fun updateByExternalId( + params: CustomerUpdateByExternalIdParams + ): CompletableFuture> = + updateByExternalId(params, RequestOptions.none()) + + /** @see [updateByExternalId] */ + @MustBeClosed + fun updateByExternalId( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + updateByExternalId(id, CustomerUpdateByExternalIdParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt index 7ed7766f..203abbad 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/CustomerServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.emptyHandler import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler @@ -36,6 +37,7 @@ import com.withorb.api.services.async.customers.CostServiceAsyncImpl import com.withorb.api.services.async.customers.CreditServiceAsync import com.withorb.api.services.async.customers.CreditServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CustomerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CustomerServiceAsync { @@ -187,6 +189,9 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C params: CustomerUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -239,6 +244,7 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C .let { CustomerListPageAsync.builder() .service(CustomerServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -253,6 +259,9 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C params: CustomerDeleteParams, requestOptions: RequestOptions, ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -275,6 +284,9 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C params: CustomerFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -304,6 +316,9 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C params: CustomerFetchByExternalIdParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -333,6 +348,9 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C params: CustomerSyncPaymentMethodsFromGatewayParams, requestOptions: RequestOptions, ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -361,6 +379,9 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams, requestOptions: RequestOptions, ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -392,6 +413,9 @@ class CustomerServiceAsyncImpl internal constructor(private val clientOptions: C params: CustomerUpdateByExternalIdParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) 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 d50338f5..b9f463fc 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 @@ -42,9 +42,26 @@ interface DimensionalPriceGroupServiceAsync { ): CompletableFuture /** Fetch dimensional price group */ + fun retrieve(dimensionalPriceGroupId: String): CompletableFuture = + retrieve(dimensionalPriceGroupId, DimensionalPriceGroupRetrieveParams.none()) + + /** @see [retrieve] */ fun retrieve( - params: DimensionalPriceGroupRetrieveParams - ): CompletableFuture = retrieve(params, RequestOptions.none()) + dimensionalPriceGroupId: String, + params: DimensionalPriceGroupRetrieveParams = DimensionalPriceGroupRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve( + params.toBuilder().dimensionalPriceGroupId(dimensionalPriceGroupId).build(), + requestOptions, + ) + + /** @see [retrieve] */ + fun retrieve( + dimensionalPriceGroupId: String, + params: DimensionalPriceGroupRetrieveParams = DimensionalPriceGroupRetrieveParams.none(), + ): CompletableFuture = + retrieve(dimensionalPriceGroupId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -52,6 +69,22 @@ interface DimensionalPriceGroupServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve( + params: DimensionalPriceGroupRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + dimensionalPriceGroupId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve( + dimensionalPriceGroupId, + DimensionalPriceGroupRetrieveParams.none(), + requestOptions, + ) + /** List dimensional price groups */ fun list(): CompletableFuture = list(DimensionalPriceGroupListParams.none()) @@ -106,9 +139,30 @@ interface DimensionalPriceGroupServiceAsync { */ @MustBeClosed fun retrieve( - params: DimensionalPriceGroupRetrieveParams + dimensionalPriceGroupId: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(dimensionalPriceGroupId, DimensionalPriceGroupRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + dimensionalPriceGroupId: String, + params: DimensionalPriceGroupRetrieveParams = + DimensionalPriceGroupRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve( + params.toBuilder().dimensionalPriceGroupId(dimensionalPriceGroupId).build(), + requestOptions, + ) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + dimensionalPriceGroupId: String, + params: DimensionalPriceGroupRetrieveParams = DimensionalPriceGroupRetrieveParams.none(), + ): CompletableFuture> = + retrieve(dimensionalPriceGroupId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -117,6 +171,25 @@ interface DimensionalPriceGroupServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: DimensionalPriceGroupRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + dimensionalPriceGroupId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve( + dimensionalPriceGroupId, + DimensionalPriceGroupRetrieveParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `get /dimensional_price_groups`, but is otherwise the * same as [DimensionalPriceGroupServiceAsync.list]. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt index b6523976..8588a90b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -24,6 +25,7 @@ import com.withorb.api.models.DimensionalPriceGroups import com.withorb.api.services.async.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdServiceAsync import com.withorb.api.services.async.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class DimensionalPriceGroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : DimensionalPriceGroupServiceAsync { @@ -117,6 +119,9 @@ internal constructor(private val clientOptions: ClientOptions) : DimensionalPric params: DimensionalPriceGroupRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("dimensionalPriceGroupId", params.dimensionalPriceGroupId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -168,6 +173,7 @@ internal constructor(private val clientOptions: ClientOptions) : DimensionalPric .let { DimensionalPriceGroupListPageAsync.builder() .service(DimensionalPriceGroupServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() 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 8d64fda3..dee66686 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 @@ -69,6 +69,18 @@ interface EventServiceAsync { * period. For higher volume updates, consider using the [event backfill](create-backfill) * endpoint. */ + fun update(eventId: String, params: EventUpdateParams): CompletableFuture = + update(eventId, params, RequestOptions.none()) + + /** @see [update] */ + fun update( + eventId: String, + params: EventUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().eventId(eventId).build(), requestOptions) + + /** @see [update] */ fun update(params: EventUpdateParams): CompletableFuture = update(params, RequestOptions.none()) @@ -114,8 +126,22 @@ interface EventServiceAsync { * period. For higher volume updates, consider using the [event backfill](create-backfill) * endpoint. */ - fun deprecate(params: EventDeprecateParams): CompletableFuture = - deprecate(params, RequestOptions.none()) + fun deprecate(eventId: String): CompletableFuture = + deprecate(eventId, EventDeprecateParams.none()) + + /** @see [deprecate] */ + fun deprecate( + eventId: String, + params: EventDeprecateParams = EventDeprecateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + deprecate(params.toBuilder().eventId(eventId).build(), requestOptions) + + /** @see [deprecate] */ + fun deprecate( + eventId: String, + params: EventDeprecateParams = EventDeprecateParams.none(), + ): CompletableFuture = deprecate(eventId, params, RequestOptions.none()) /** @see [deprecate] */ fun deprecate( @@ -123,6 +149,17 @@ interface EventServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [deprecate] */ + fun deprecate(params: EventDeprecateParams): CompletableFuture = + deprecate(params, RequestOptions.none()) + + /** @see [deprecate] */ + fun deprecate( + eventId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + deprecate(eventId, EventDeprecateParams.none(), requestOptions) + /** * Orb's event ingestion model and API is designed around two core principles: * 1. **Data fidelity**: The accuracy of your billing model depends on a robust foundation of @@ -360,6 +397,23 @@ interface EventServiceAsync { * [EventServiceAsync.update]. */ @MustBeClosed + fun update( + eventId: String, + params: EventUpdateParams, + ): CompletableFuture> = + update(eventId, params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + eventId: String, + params: EventUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().eventId(eventId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed fun update( params: EventUpdateParams ): CompletableFuture> = @@ -377,10 +431,25 @@ interface EventServiceAsync { * same as [EventServiceAsync.deprecate]. */ @MustBeClosed + fun deprecate(eventId: String): CompletableFuture> = + deprecate(eventId, EventDeprecateParams.none()) + + /** @see [deprecate] */ + @MustBeClosed fun deprecate( - params: EventDeprecateParams + eventId: String, + params: EventDeprecateParams = EventDeprecateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - deprecate(params, RequestOptions.none()) + deprecate(params.toBuilder().eventId(eventId).build(), requestOptions) + + /** @see [deprecate] */ + @MustBeClosed + fun deprecate( + eventId: String, + params: EventDeprecateParams = EventDeprecateParams.none(), + ): CompletableFuture> = + deprecate(eventId, params, RequestOptions.none()) /** @see [deprecate] */ @MustBeClosed @@ -389,6 +458,21 @@ interface EventServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [deprecate] */ + @MustBeClosed + fun deprecate( + params: EventDeprecateParams + ): CompletableFuture> = + deprecate(params, RequestOptions.none()) + + /** @see [deprecate] */ + @MustBeClosed + fun deprecate( + eventId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + deprecate(eventId, EventDeprecateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /ingest`, but is otherwise the same as * [EventServiceAsync.ingest]. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt index 02d350b0..84575534 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/EventServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -28,6 +29,7 @@ import com.withorb.api.services.async.events.BackfillServiceAsyncImpl import com.withorb.api.services.async.events.VolumeServiceAsync import com.withorb.api.services.async.events.VolumeServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class EventServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EventServiceAsync { @@ -99,6 +101,9 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie params: EventUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("eventId", params.eventId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -130,6 +135,9 @@ class EventServiceAsyncImpl internal constructor(private val clientOptions: Clie params: EventDeprecateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("eventId", params.eventId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) 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 46eeeaa5..175dc7e6 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 @@ -42,8 +42,22 @@ interface InvoiceServiceAsync { * * `metadata` can be modified regardless of invoice state. */ - fun update(params: InvoiceUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(invoiceId: String): CompletableFuture = + update(invoiceId, InvoiceUpdateParams.none()) + + /** @see [update] */ + fun update( + invoiceId: String, + params: InvoiceUpdateParams = InvoiceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [update] */ + fun update( + invoiceId: String, + params: InvoiceUpdateParams = InvoiceUpdateParams.none(), + ): CompletableFuture = update(invoiceId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -51,6 +65,14 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: InvoiceUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(invoiceId: String, requestOptions: RequestOptions): CompletableFuture = + update(invoiceId, InvoiceUpdateParams.none(), requestOptions) + /** * This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s for an account in a * list format. @@ -85,8 +107,22 @@ interface InvoiceServiceAsync { /** * This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an identifier. */ - fun fetch(params: InvoiceFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(invoiceId: String): CompletableFuture = + fetch(invoiceId, InvoiceFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + invoiceId: String, + params: InvoiceFetchParams = InvoiceFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetch(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + invoiceId: String, + params: InvoiceFetchParams = InvoiceFetchParams.none(), + ): CompletableFuture = fetch(invoiceId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -94,6 +130,14 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: InvoiceFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(invoiceId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(invoiceId, InvoiceFetchParams.none(), requestOptions) + /** * This endpoint can be used to fetch the upcoming [invoice](/core-concepts#invoice) for the * current billing period given a subscription. @@ -116,8 +160,22 @@ interface InvoiceServiceAsync { * could be customer-visible (e.g. sending emails, auto-collecting payment, syncing the invoice * to external providers, etc). */ - fun issue(params: InvoiceIssueParams): CompletableFuture = - issue(params, RequestOptions.none()) + fun issue(invoiceId: String): CompletableFuture = + issue(invoiceId, InvoiceIssueParams.none()) + + /** @see [issue] */ + fun issue( + invoiceId: String, + params: InvoiceIssueParams = InvoiceIssueParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + issue(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [issue] */ + fun issue( + invoiceId: String, + params: InvoiceIssueParams = InvoiceIssueParams.none(), + ): CompletableFuture = issue(invoiceId, params, RequestOptions.none()) /** @see [issue] */ fun issue( @@ -125,10 +183,30 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [issue] */ + fun issue(params: InvoiceIssueParams): CompletableFuture = + issue(params, RequestOptions.none()) + + /** @see [issue] */ + fun issue(invoiceId: String, requestOptions: RequestOptions): CompletableFuture = + 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. */ + fun markPaid(invoiceId: String, params: InvoiceMarkPaidParams): CompletableFuture = + markPaid(invoiceId, params, RequestOptions.none()) + + /** @see [markPaid] */ + fun markPaid( + invoiceId: String, + params: InvoiceMarkPaidParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + markPaid(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [markPaid] */ fun markPaid(params: InvoiceMarkPaidParams): CompletableFuture = markPaid(params, RequestOptions.none()) @@ -142,8 +220,21 @@ interface InvoiceServiceAsync { * This endpoint collects payment for an invoice using the customer's default payment method. * This action can only be taken on invoices with status "issued". */ - fun pay(params: InvoicePayParams): CompletableFuture = - pay(params, RequestOptions.none()) + fun pay(invoiceId: String): CompletableFuture = pay(invoiceId, InvoicePayParams.none()) + + /** @see [pay] */ + fun pay( + invoiceId: String, + params: InvoicePayParams = InvoicePayParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + pay(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [pay] */ + fun pay( + invoiceId: String, + params: InvoicePayParams = InvoicePayParams.none(), + ): CompletableFuture = pay(invoiceId, params, RequestOptions.none()) /** @see [pay] */ fun pay( @@ -151,6 +242,14 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [pay] */ + fun pay(params: InvoicePayParams): CompletableFuture = + pay(params, RequestOptions.none()) + + /** @see [pay] */ + fun pay(invoiceId: String, requestOptions: RequestOptions): CompletableFuture = + 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. @@ -163,8 +262,22 @@ interface InvoiceServiceAsync { * credit block will be voided. If the invoice was created due to a top-up, the top-up will be * disabled. */ - fun voidInvoice(params: InvoiceVoidInvoiceParams): CompletableFuture = - voidInvoice(params, RequestOptions.none()) + fun voidInvoice(invoiceId: String): CompletableFuture = + voidInvoice(invoiceId, InvoiceVoidInvoiceParams.none()) + + /** @see [voidInvoice] */ + fun voidInvoice( + invoiceId: String, + params: InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + voidInvoice(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [voidInvoice] */ + fun voidInvoice( + invoiceId: String, + params: InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams.none(), + ): CompletableFuture = voidInvoice(invoiceId, params, RequestOptions.none()) /** @see [voidInvoice] */ fun voidInvoice( @@ -172,6 +285,14 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [voidInvoice] */ + fun voidInvoice(params: InvoiceVoidInvoiceParams): CompletableFuture = + voidInvoice(params, RequestOptions.none()) + + /** @see [voidInvoice] */ + fun voidInvoice(invoiceId: String, requestOptions: RequestOptions): CompletableFuture = + voidInvoice(invoiceId, InvoiceVoidInvoiceParams.none(), requestOptions) + /** * A view of [InvoiceServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -197,8 +318,25 @@ interface InvoiceServiceAsync { * as [InvoiceServiceAsync.update]. */ @MustBeClosed - fun update(params: InvoiceUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + fun update(invoiceId: String): CompletableFuture> = + update(invoiceId, InvoiceUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + invoiceId: String, + params: InvoiceUpdateParams = InvoiceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + invoiceId: String, + params: InvoiceUpdateParams = InvoiceUpdateParams.none(), + ): CompletableFuture> = + update(invoiceId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -207,6 +345,19 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update(params: InvoiceUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + invoiceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(invoiceId, InvoiceUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices`, but is otherwise the same as * [InvoiceServiceAsync.list]. @@ -241,8 +392,25 @@ interface InvoiceServiceAsync { * as [InvoiceServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: InvoiceFetchParams): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(invoiceId: String): CompletableFuture> = + fetch(invoiceId, InvoiceFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + invoiceId: String, + params: InvoiceFetchParams = InvoiceFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + invoiceId: String, + params: InvoiceFetchParams = InvoiceFetchParams.none(), + ): CompletableFuture> = + fetch(invoiceId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -251,6 +419,19 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: InvoiceFetchParams): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + invoiceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(invoiceId, InvoiceFetchParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices/upcoming`, but is otherwise the same as * [InvoiceServiceAsync.fetchUpcoming]. @@ -273,8 +454,25 @@ interface InvoiceServiceAsync { * same as [InvoiceServiceAsync.issue]. */ @MustBeClosed - fun issue(params: InvoiceIssueParams): CompletableFuture> = - issue(params, RequestOptions.none()) + fun issue(invoiceId: String): CompletableFuture> = + issue(invoiceId, InvoiceIssueParams.none()) + + /** @see [issue] */ + @MustBeClosed + fun issue( + invoiceId: String, + params: InvoiceIssueParams = InvoiceIssueParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + issue(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [issue] */ + @MustBeClosed + fun issue( + invoiceId: String, + params: InvoiceIssueParams = InvoiceIssueParams.none(), + ): CompletableFuture> = + issue(invoiceId, params, RequestOptions.none()) /** @see [issue] */ @MustBeClosed @@ -283,11 +481,41 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [issue] */ + @MustBeClosed + fun issue(params: InvoiceIssueParams): CompletableFuture> = + issue(params, RequestOptions.none()) + + /** @see [issue] */ + @MustBeClosed + fun issue( + invoiceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /invoices/{invoice_id}/mark_paid`, but is otherwise * the same as [InvoiceServiceAsync.markPaid]. */ @MustBeClosed + fun markPaid( + invoiceId: String, + params: InvoiceMarkPaidParams, + ): CompletableFuture> = + markPaid(invoiceId, params, RequestOptions.none()) + + /** @see [markPaid] */ + @MustBeClosed + fun markPaid( + invoiceId: String, + params: InvoiceMarkPaidParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + markPaid(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [markPaid] */ + @MustBeClosed fun markPaid(params: InvoiceMarkPaidParams): CompletableFuture> = markPaid(params, RequestOptions.none()) @@ -303,8 +531,25 @@ interface InvoiceServiceAsync { * same as [InvoiceServiceAsync.pay]. */ @MustBeClosed - fun pay(params: InvoicePayParams): CompletableFuture> = - pay(params, RequestOptions.none()) + fun pay(invoiceId: String): CompletableFuture> = + pay(invoiceId, InvoicePayParams.none()) + + /** @see [pay] */ + @MustBeClosed + fun pay( + invoiceId: String, + params: InvoicePayParams = InvoicePayParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + pay(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [pay] */ + @MustBeClosed + fun pay( + invoiceId: String, + params: InvoicePayParams = InvoicePayParams.none(), + ): CompletableFuture> = + pay(invoiceId, params, RequestOptions.none()) /** @see [pay] */ @MustBeClosed @@ -313,14 +558,43 @@ interface InvoiceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [pay] */ + @MustBeClosed + fun pay(params: InvoicePayParams): CompletableFuture> = + pay(params, RequestOptions.none()) + + /** @see [pay] */ + @MustBeClosed + fun pay( + invoiceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + pay(invoiceId, InvoicePayParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /invoices/{invoice_id}/void`, but is otherwise the * same as [InvoiceServiceAsync.voidInvoice]. */ @MustBeClosed + fun voidInvoice(invoiceId: String): CompletableFuture> = + voidInvoice(invoiceId, InvoiceVoidInvoiceParams.none()) + + /** @see [voidInvoice] */ + @MustBeClosed fun voidInvoice( - params: InvoiceVoidInvoiceParams - ): CompletableFuture> = voidInvoice(params, RequestOptions.none()) + invoiceId: String, + params: InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + voidInvoice(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [voidInvoice] */ + @MustBeClosed + fun voidInvoice( + invoiceId: String, + params: InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams.none(), + ): CompletableFuture> = + voidInvoice(invoiceId, params, RequestOptions.none()) /** @see [voidInvoice] */ @MustBeClosed @@ -328,5 +602,19 @@ interface InvoiceServiceAsync { params: InvoiceVoidInvoiceParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [voidInvoice] */ + @MustBeClosed + fun voidInvoice( + params: InvoiceVoidInvoiceParams + ): CompletableFuture> = voidInvoice(params, RequestOptions.none()) + + /** @see [voidInvoice] */ + @MustBeClosed + fun voidInvoice( + invoiceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + voidInvoice(invoiceId, InvoiceVoidInvoiceParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt index e63e0397..4470c68a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/InvoiceServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -29,6 +30,7 @@ import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceServiceAsync { @@ -144,6 +146,9 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl params: InvoiceUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -196,6 +201,7 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl .let { InvoiceListPageAsync.builder() .service(InvoiceServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -211,6 +217,9 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl params: InvoiceFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -270,6 +279,9 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl params: InvoiceIssueParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -300,6 +312,9 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl params: InvoiceMarkPaidParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -330,6 +345,9 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl params: InvoicePayParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -360,6 +378,9 @@ class InvoiceServiceAsyncImpl internal constructor(private val clientOptions: Cl params: InvoiceVoidInvoiceParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt index 2cb003e2..e39208eb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsync.kt @@ -31,8 +31,20 @@ interface ItemServiceAsync { ): CompletableFuture /** This endpoint can be used to update properties on the Item. */ - fun update(params: ItemUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(itemId: String): CompletableFuture = update(itemId, ItemUpdateParams.none()) + + /** @see [update] */ + fun update( + itemId: String, + params: ItemUpdateParams = ItemUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = update(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see [update] */ + fun update( + itemId: String, + params: ItemUpdateParams = ItemUpdateParams.none(), + ): CompletableFuture = update(itemId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -40,6 +52,14 @@ interface ItemServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: ItemUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(itemId: String, requestOptions: RequestOptions): CompletableFuture = + update(itemId, ItemUpdateParams.none(), requestOptions) + /** This endpoint returns a list of all Items, ordered in descending order by creation time. */ fun list(): CompletableFuture = list(ItemListParams.none()) @@ -58,8 +78,20 @@ interface ItemServiceAsync { list(ItemListParams.none(), requestOptions) /** This endpoint returns an item identified by its item_id. */ - fun fetch(params: ItemFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(itemId: String): CompletableFuture = fetch(itemId, ItemFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + itemId: String, + params: ItemFetchParams = ItemFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = fetch(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + itemId: String, + params: ItemFetchParams = ItemFetchParams.none(), + ): CompletableFuture = fetch(itemId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -67,6 +99,14 @@ interface ItemServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: ItemFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(itemId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(itemId, ItemFetchParams.none(), requestOptions) + /** A view of [ItemServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -90,8 +130,24 @@ interface ItemServiceAsync { * [ItemServiceAsync.update]. */ @MustBeClosed - fun update(params: ItemUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + fun update(itemId: String): CompletableFuture> = + update(itemId, ItemUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + itemId: String, + params: ItemUpdateParams = ItemUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + itemId: String, + params: ItemUpdateParams = ItemUpdateParams.none(), + ): CompletableFuture> = update(itemId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -100,6 +156,19 @@ interface ItemServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update(params: ItemUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + itemId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(itemId, ItemUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /items`, but is otherwise the same as * [ItemServiceAsync.list]. @@ -134,8 +203,24 @@ interface ItemServiceAsync { * [ItemServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: ItemFetchParams): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(itemId: String): CompletableFuture> = + fetch(itemId, ItemFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + itemId: String, + params: ItemFetchParams = ItemFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + itemId: String, + params: ItemFetchParams = ItemFetchParams.none(), + ): CompletableFuture> = fetch(itemId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -143,5 +228,18 @@ interface ItemServiceAsync { params: ItemFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: ItemFetchParams): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + itemId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(itemId, ItemFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt index 3bca007f..c96f026f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/ItemServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -23,6 +24,7 @@ import com.withorb.api.models.ItemListPageResponse import com.withorb.api.models.ItemListParams import com.withorb.api.models.ItemUpdateParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class ItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ItemServiceAsync { @@ -103,6 +105,9 @@ class ItemServiceAsyncImpl internal constructor(private val clientOptions: Clien params: ItemUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("itemId", params.itemId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -155,6 +160,7 @@ class ItemServiceAsyncImpl internal constructor(private val clientOptions: Clien .let { ItemListPageAsync.builder() .service(ItemServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -170,6 +176,9 @@ class ItemServiceAsyncImpl internal constructor(private val clientOptions: Clien params: ItemFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("itemId", params.itemId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt index 554e58ce..e865ac45 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsync.kt @@ -38,8 +38,22 @@ interface MetricServiceAsync { * This endpoint allows you to update the `metadata` property on a metric. If you pass `null` * for the metadata value, it will clear any existing metadata for that invoice. */ - fun update(params: MetricUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(metricId: String): CompletableFuture = + update(metricId, MetricUpdateParams.none()) + + /** @see [update] */ + fun update( + metricId: String, + params: MetricUpdateParams = MetricUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().metricId(metricId).build(), requestOptions) + + /** @see [update] */ + fun update( + metricId: String, + params: MetricUpdateParams = MetricUpdateParams.none(), + ): CompletableFuture = update(metricId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -47,6 +61,17 @@ interface MetricServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: MetricUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + metricId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(metricId, MetricUpdateParams.none(), requestOptions) + /** * This endpoint is used to fetch [metric](/core-concepts##metric) details given a metric * identifier. It returns information about the metrics including its name, description, and @@ -73,8 +98,22 @@ interface MetricServiceAsync { * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about * the metrics including its name, description, and item. */ - fun fetch(params: MetricFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(metricId: String): CompletableFuture = + fetch(metricId, MetricFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + metricId: String, + params: MetricFetchParams = MetricFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetch(params.toBuilder().metricId(metricId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + metricId: String, + params: MetricFetchParams = MetricFetchParams.none(), + ): CompletableFuture = fetch(metricId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -82,6 +121,14 @@ interface MetricServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: MetricFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(metricId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(metricId, MetricFetchParams.none(), requestOptions) + /** * A view of [MetricServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -107,8 +154,25 @@ interface MetricServiceAsync { * [MetricServiceAsync.update]. */ @MustBeClosed - fun update(params: MetricUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + fun update(metricId: String): CompletableFuture> = + update(metricId, MetricUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + metricId: String, + params: MetricUpdateParams = MetricUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().metricId(metricId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + metricId: String, + params: MetricUpdateParams = MetricUpdateParams.none(), + ): CompletableFuture> = + update(metricId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -117,6 +181,19 @@ interface MetricServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update(params: MetricUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + metricId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(metricId, MetricUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /metrics`, but is otherwise the same as * [MetricServiceAsync.list]. @@ -151,8 +228,25 @@ interface MetricServiceAsync { * [MetricServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: MetricFetchParams): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(metricId: String): CompletableFuture> = + fetch(metricId, MetricFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + metricId: String, + params: MetricFetchParams = MetricFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().metricId(metricId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + metricId: String, + params: MetricFetchParams = MetricFetchParams.none(), + ): CompletableFuture> = + fetch(metricId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -160,5 +254,18 @@ interface MetricServiceAsync { params: MetricFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: MetricFetchParams): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + metricId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(metricId, MetricFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt index 7fcfab11..9c2a533b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/MetricServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -23,6 +24,7 @@ import com.withorb.api.models.MetricListPageResponse import com.withorb.api.models.MetricListParams import com.withorb.api.models.MetricUpdateParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class MetricServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : MetricServiceAsync { @@ -103,6 +105,9 @@ class MetricServiceAsyncImpl internal constructor(private val clientOptions: Cli params: MetricUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("metricId", params.metricId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -155,6 +160,7 @@ class MetricServiceAsyncImpl internal constructor(private val clientOptions: Cli .let { MetricListPageAsync.builder() .service(MetricServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -170,6 +176,9 @@ class MetricServiceAsyncImpl internal constructor(private val clientOptions: Cli params: MetricFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("metricId", params.metricId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 28590f41..ba6eeda3 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 @@ -39,8 +39,20 @@ interface PlanServiceAsync { * * Other fields on a customer are currently immutable. */ - fun update(params: PlanUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(planId: String): CompletableFuture = update(planId, PlanUpdateParams.none()) + + /** @see [update] */ + fun update( + planId: String, + params: PlanUpdateParams = PlanUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = update(params.toBuilder().planId(planId).build(), requestOptions) + + /** @see [update] */ + fun update( + planId: String, + params: PlanUpdateParams = PlanUpdateParams.none(), + ): CompletableFuture = update(planId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -48,6 +60,14 @@ interface PlanServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: PlanUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(planId: String, requestOptions: RequestOptions): CompletableFuture = + update(planId, PlanUpdateParams.none(), requestOptions) + /** * This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for an account in * a list format. The list of plans is ordered starting from the most recently created plan. The @@ -88,8 +108,20 @@ interface PlanServiceAsync { * Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized * prices refer to all prices across all phases. */ - fun fetch(params: PlanFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(planId: String): CompletableFuture = fetch(planId, PlanFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + planId: String, + params: PlanFetchParams = PlanFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = fetch(params.toBuilder().planId(planId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + planId: String, + params: PlanFetchParams = PlanFetchParams.none(), + ): CompletableFuture = fetch(planId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -97,6 +129,14 @@ interface PlanServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: PlanFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(planId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(planId, PlanFetchParams.none(), requestOptions) + /** A view of [PlanServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -122,8 +162,24 @@ interface PlanServiceAsync { * [PlanServiceAsync.update]. */ @MustBeClosed - fun update(params: PlanUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + fun update(planId: String): CompletableFuture> = + update(planId, PlanUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + planId: String, + params: PlanUpdateParams = PlanUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().planId(planId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + planId: String, + params: PlanUpdateParams = PlanUpdateParams.none(), + ): CompletableFuture> = update(planId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -132,6 +188,19 @@ interface PlanServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update(params: PlanUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + planId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(planId, PlanUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /plans`, but is otherwise the same as * [PlanServiceAsync.list]. @@ -166,8 +235,24 @@ interface PlanServiceAsync { * [PlanServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: PlanFetchParams): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(planId: String): CompletableFuture> = + fetch(planId, PlanFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + planId: String, + params: PlanFetchParams = PlanFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().planId(planId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + planId: String, + params: PlanFetchParams = PlanFetchParams.none(), + ): CompletableFuture> = fetch(planId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -175,5 +260,18 @@ interface PlanServiceAsync { params: PlanFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: PlanFetchParams): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + planId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(planId, PlanFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt index 6ed6bd37..5a2dc237 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PlanServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import com.withorb.api.models.PlanUpdateParams import com.withorb.api.services.async.plans.ExternalPlanIdServiceAsync import com.withorb.api.services.async.plans.ExternalPlanIdServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class PlanServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PlanServiceAsync { @@ -117,6 +119,9 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien params: PlanUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("planId", params.planId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -169,6 +174,7 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien .let { PlanListPageAsync.builder() .service(PlanServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -184,6 +190,9 @@ class PlanServiceAsyncImpl internal constructor(private val clientOptions: Clien params: PlanFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("planId", params.planId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt index ae0f5ebb..75f167ea 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsync.kt @@ -50,8 +50,22 @@ interface PriceServiceAsync { * This endpoint allows you to update the `metadata` property on a price. If you pass null for * the metadata value, it will clear any existing metadata for that price. */ - fun update(params: PriceUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(priceId: String): CompletableFuture = + update(priceId, PriceUpdateParams.none()) + + /** @see [update] */ + fun update( + priceId: String, + params: PriceUpdateParams = PriceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [update] */ + fun update( + priceId: String, + params: PriceUpdateParams = PriceUpdateParams.none(), + ): CompletableFuture = update(priceId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -59,6 +73,14 @@ interface PriceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: PriceUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(priceId: String, requestOptions: RequestOptions): CompletableFuture = + update(priceId, PriceUpdateParams.none(), requestOptions) + /** * This endpoint is used to list all add-on prices created using the * [price creation endpoint](/api-reference/price/create-price). @@ -99,6 +121,20 @@ interface PriceServiceAsync { * the results must be no greater than 1000. Note that this is a POST endpoint rather than a GET * endpoint because it employs a JSON body rather than query parameters. */ + fun evaluate( + priceId: String, + params: PriceEvaluateParams, + ): CompletableFuture = evaluate(priceId, params, RequestOptions.none()) + + /** @see [evaluate] */ + fun evaluate( + priceId: String, + params: PriceEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + evaluate(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [evaluate] */ fun evaluate(params: PriceEvaluateParams): CompletableFuture = evaluate(params, RequestOptions.none()) @@ -109,8 +145,20 @@ interface PriceServiceAsync { ): CompletableFuture /** This endpoint returns a price given an identifier. */ - fun fetch(params: PriceFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(priceId: String): CompletableFuture = fetch(priceId, PriceFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + priceId: String, + params: PriceFetchParams = PriceFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = fetch(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + priceId: String, + params: PriceFetchParams = PriceFetchParams.none(), + ): CompletableFuture = fetch(priceId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -118,6 +166,14 @@ interface PriceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: PriceFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(priceId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(priceId, PriceFetchParams.none(), requestOptions) + /** A view of [PriceServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -143,8 +199,25 @@ interface PriceServiceAsync { * [PriceServiceAsync.update]. */ @MustBeClosed - fun update(params: PriceUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) + fun update(priceId: String): CompletableFuture> = + update(priceId, PriceUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + priceId: String, + params: PriceUpdateParams = PriceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + priceId: String, + params: PriceUpdateParams = PriceUpdateParams.none(), + ): CompletableFuture> = + update(priceId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -153,6 +226,19 @@ interface PriceServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update(params: PriceUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + priceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(priceId, PriceUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /prices`, but is otherwise the same as * [PriceServiceAsync.list]. @@ -187,6 +273,23 @@ interface PriceServiceAsync { * same as [PriceServiceAsync.evaluate]. */ @MustBeClosed + fun evaluate( + priceId: String, + params: PriceEvaluateParams, + ): CompletableFuture> = + evaluate(priceId, params, RequestOptions.none()) + + /** @see [evaluate] */ + @MustBeClosed + fun evaluate( + priceId: String, + params: PriceEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + evaluate(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [evaluate] */ + @MustBeClosed fun evaluate( params: PriceEvaluateParams ): CompletableFuture> = @@ -204,8 +307,24 @@ interface PriceServiceAsync { * [PriceServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: PriceFetchParams): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(priceId: String): CompletableFuture> = + fetch(priceId, PriceFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + priceId: String, + params: PriceFetchParams = PriceFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + priceId: String, + params: PriceFetchParams = PriceFetchParams.none(), + ): CompletableFuture> = fetch(priceId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -213,5 +332,18 @@ interface PriceServiceAsync { params: PriceFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: PriceFetchParams): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + priceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(priceId, PriceFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt index 0e1e32a6..af00ee2e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/PriceServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -27,6 +28,7 @@ import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsync import com.withorb.api.services.async.prices.ExternalPriceIdServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class PriceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PriceServiceAsync { @@ -127,6 +129,9 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie params: PriceUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("priceId", params.priceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -179,6 +184,7 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie .let { PriceListPageAsync.builder() .service(PriceServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -195,6 +201,9 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie params: PriceEvaluateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("priceId", params.priceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -225,6 +234,9 @@ class PriceServiceAsyncImpl internal constructor(private val clientOptions: Clie params: PriceFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("priceId", params.priceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsync.kt index 99380e5b..40fcbfbb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsync.kt @@ -31,9 +31,27 @@ interface SubscriptionChangeServiceAsync { * response. */ fun retrieve( - params: SubscriptionChangeRetrieveParams + subscriptionChangeId: String ): CompletableFuture = - retrieve(params, RequestOptions.none()) + retrieve(subscriptionChangeId, SubscriptionChangeRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + subscriptionChangeId: String, + params: SubscriptionChangeRetrieveParams = SubscriptionChangeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [retrieve] */ + fun retrieve( + subscriptionChangeId: String, + params: SubscriptionChangeRetrieveParams = SubscriptionChangeRetrieveParams.none(), + ): CompletableFuture = + retrieve(subscriptionChangeId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -41,14 +59,41 @@ interface SubscriptionChangeServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve( + params: SubscriptionChangeRetrieveParams + ): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(subscriptionChangeId, SubscriptionChangeRetrieveParams.none(), requestOptions) + /** * Apply a subscription change to perform the intended action. If a positive amount is passed * with a request to this endpoint, any eligible invoices that were created will be issued * immediately if they only contain in-advance fees. */ + fun apply(subscriptionChangeId: String): CompletableFuture = + apply(subscriptionChangeId, SubscriptionChangeApplyParams.none()) + + /** @see [apply] */ fun apply( - params: SubscriptionChangeApplyParams - ): CompletableFuture = apply(params, RequestOptions.none()) + subscriptionChangeId: String, + params: SubscriptionChangeApplyParams = SubscriptionChangeApplyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + apply(params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), requestOptions) + + /** @see [apply] */ + fun apply( + subscriptionChangeId: String, + params: SubscriptionChangeApplyParams = SubscriptionChangeApplyParams.none(), + ): CompletableFuture = + apply(subscriptionChangeId, params, RequestOptions.none()) /** @see [apply] */ fun apply( @@ -56,14 +101,43 @@ interface SubscriptionChangeServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [apply] */ + fun apply( + params: SubscriptionChangeApplyParams + ): CompletableFuture = apply(params, RequestOptions.none()) + + /** @see [apply] */ + fun apply( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + apply(subscriptionChangeId, SubscriptionChangeApplyParams.none(), requestOptions) + /** * Cancel a subscription change. The change can no longer be applied. A subscription can only * have one "pending" change at a time - use this endpoint to cancel an existing change before * creating a new one. */ + fun cancel(subscriptionChangeId: String): CompletableFuture = + cancel(subscriptionChangeId, SubscriptionChangeCancelParams.none()) + + /** @see [cancel] */ fun cancel( - params: SubscriptionChangeCancelParams - ): CompletableFuture = cancel(params, RequestOptions.none()) + subscriptionChangeId: String, + params: SubscriptionChangeCancelParams = SubscriptionChangeCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [cancel] */ + fun cancel( + subscriptionChangeId: String, + params: SubscriptionChangeCancelParams = SubscriptionChangeCancelParams.none(), + ): CompletableFuture = + cancel(subscriptionChangeId, params, RequestOptions.none()) /** @see [cancel] */ fun cancel( @@ -71,6 +145,18 @@ interface SubscriptionChangeServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [cancel] */ + fun cancel( + params: SubscriptionChangeCancelParams + ): CompletableFuture = cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + fun cancel( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + cancel(subscriptionChangeId, SubscriptionChangeCancelParams.none(), requestOptions) + /** * A view of [SubscriptionChangeServiceAsync] that provides access to raw HTTP responses for * each method. @@ -83,9 +169,29 @@ interface SubscriptionChangeServiceAsync { */ @MustBeClosed fun retrieve( - params: SubscriptionChangeRetrieveParams + subscriptionChangeId: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve(subscriptionChangeId, SubscriptionChangeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + subscriptionChangeId: String, + params: SubscriptionChangeRetrieveParams = SubscriptionChangeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + subscriptionChangeId: String, + params: SubscriptionChangeRetrieveParams = SubscriptionChangeRetrieveParams.none(), + ): CompletableFuture> = + retrieve(subscriptionChangeId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -94,6 +200,21 @@ interface SubscriptionChangeServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: SubscriptionChangeRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(subscriptionChangeId, SubscriptionChangeRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /subscription_changes/{subscription_change_id}/apply`, but is otherwise the same as @@ -101,9 +222,29 @@ interface SubscriptionChangeServiceAsync { */ @MustBeClosed fun apply( - params: SubscriptionChangeApplyParams + subscriptionChangeId: String ): CompletableFuture> = - apply(params, RequestOptions.none()) + apply(subscriptionChangeId, SubscriptionChangeApplyParams.none()) + + /** @see [apply] */ + @MustBeClosed + fun apply( + subscriptionChangeId: String, + params: SubscriptionChangeApplyParams = SubscriptionChangeApplyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + apply( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [apply] */ + @MustBeClosed + fun apply( + subscriptionChangeId: String, + params: SubscriptionChangeApplyParams = SubscriptionChangeApplyParams.none(), + ): CompletableFuture> = + apply(subscriptionChangeId, params, RequestOptions.none()) /** @see [apply] */ @MustBeClosed @@ -112,6 +253,21 @@ interface SubscriptionChangeServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [apply] */ + @MustBeClosed + fun apply( + params: SubscriptionChangeApplyParams + ): CompletableFuture> = + apply(params, RequestOptions.none()) + + /** @see [apply] */ + @MustBeClosed + fun apply( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + apply(subscriptionChangeId, SubscriptionChangeApplyParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /subscription_changes/{subscription_change_id}/cancel`, but is otherwise the same as @@ -119,9 +275,29 @@ interface SubscriptionChangeServiceAsync { */ @MustBeClosed fun cancel( - params: SubscriptionChangeCancelParams + subscriptionChangeId: String ): CompletableFuture> = - cancel(params, RequestOptions.none()) + cancel(subscriptionChangeId, SubscriptionChangeCancelParams.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + subscriptionChangeId: String, + params: SubscriptionChangeCancelParams = SubscriptionChangeCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + subscriptionChangeId: String, + params: SubscriptionChangeCancelParams = SubscriptionChangeCancelParams.none(), + ): CompletableFuture> = + cancel(subscriptionChangeId, params, RequestOptions.none()) /** @see [cancel] */ @MustBeClosed @@ -129,5 +305,20 @@ interface SubscriptionChangeServiceAsync { params: SubscriptionChangeCancelParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + params: SubscriptionChangeCancelParams + ): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(subscriptionChangeId, SubscriptionChangeCancelParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncImpl.kt index dfa31c96..adb221d9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionChangeServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -22,6 +23,7 @@ import com.withorb.api.models.SubscriptionChangeCancelResponse import com.withorb.api.models.SubscriptionChangeRetrieveParams import com.withorb.api.models.SubscriptionChangeRetrieveResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class SubscriptionChangeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionChangeServiceAsync { @@ -66,6 +68,9 @@ internal constructor(private val clientOptions: ClientOptions) : SubscriptionCha params: SubscriptionChangeRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionChangeId", params.subscriptionChangeId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -96,6 +101,9 @@ internal constructor(private val clientOptions: ClientOptions) : SubscriptionCha params: SubscriptionChangeApplyParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionChangeId", params.subscriptionChangeId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -127,6 +135,9 @@ internal constructor(private val clientOptions: ClientOptions) : SubscriptionCha params: SubscriptionChangeCancelParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionChangeId", params.subscriptionChangeId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) 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 f05488d1..44bcb511 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 @@ -305,8 +305,22 @@ interface SubscriptionServiceAsync { * This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, * `invoicing_threshold`, and `default_invoice_memo` properties on a subscription. */ - fun update(params: SubscriptionUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(subscriptionId: String): CompletableFuture = + update(subscriptionId, SubscriptionUpdateParams.none()) + + /** @see [update] */ + fun update( + subscriptionId: String, + params: SubscriptionUpdateParams = SubscriptionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [update] */ + fun update( + subscriptionId: String, + params: SubscriptionUpdateParams = SubscriptionUpdateParams.none(), + ): CompletableFuture = update(subscriptionId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -314,6 +328,17 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: SubscriptionUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(subscriptionId, SubscriptionUpdateParams.none(), requestOptions) + /** * This endpoint returns a list of all subscriptions for an account as a * [paginated](/api-reference/pagination) list, ordered starting from the most recently created @@ -394,6 +419,21 @@ interface SubscriptionServiceAsync { * invoice and generate a new one based on the new dates for the subscription. See the section * on [cancellation behaviors](/product-catalog/creating-subscriptions#cancellation-behaviors). */ + fun cancel( + subscriptionId: String, + params: SubscriptionCancelParams, + ): CompletableFuture = + cancel(subscriptionId, params, RequestOptions.none()) + + /** @see [cancel] */ + fun cancel( + subscriptionId: String, + params: SubscriptionCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [cancel] */ fun cancel(params: SubscriptionCancelParams): CompletableFuture = cancel(params, RequestOptions.none()) @@ -407,8 +447,22 @@ interface SubscriptionServiceAsync { * This endpoint is used to fetch a [Subscription](/core-concepts##subscription) given an * identifier. */ - fun fetch(params: SubscriptionFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(subscriptionId: String): CompletableFuture = + fetch(subscriptionId, SubscriptionFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + subscriptionId: String, + params: SubscriptionFetchParams = SubscriptionFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetch(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + subscriptionId: String, + params: SubscriptionFetchParams = SubscriptionFetchParams.none(), + ): CompletableFuture = fetch(subscriptionId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -416,6 +470,17 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: SubscriptionFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + fetch(subscriptionId, SubscriptionFetchParams.none(), requestOptions) + /** * This endpoint is used to fetch a day-by-day snapshot of a subscription's costs in Orb, * calculated by applying pricing information to the underlying usage (see the @@ -427,9 +492,23 @@ interface SubscriptionServiceAsync { * of costs to a specific subscription for the customer (e.g. to de-aggregate costs when a * customer's subscription has started and stopped on the same day). */ + fun fetchCosts(subscriptionId: String): CompletableFuture = + fetchCosts(subscriptionId, SubscriptionFetchCostsParams.none()) + + /** @see [fetchCosts] */ fun fetchCosts( - params: SubscriptionFetchCostsParams - ): CompletableFuture = fetchCosts(params, RequestOptions.none()) + subscriptionId: String, + params: SubscriptionFetchCostsParams = SubscriptionFetchCostsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetchCosts(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchCosts] */ + fun fetchCosts( + subscriptionId: String, + params: SubscriptionFetchCostsParams = SubscriptionFetchCostsParams.none(), + ): CompletableFuture = + fetchCosts(subscriptionId, params, RequestOptions.none()) /** @see [fetchCosts] */ fun fetchCosts( @@ -437,15 +516,42 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetchCosts] */ + fun fetchCosts( + params: SubscriptionFetchCostsParams + ): CompletableFuture = fetchCosts(params, RequestOptions.none()) + + /** @see [fetchCosts] */ + fun fetchCosts( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + fetchCosts(subscriptionId, SubscriptionFetchCostsParams.none(), requestOptions) + /** * This endpoint returns a [paginated](/api-reference/pagination) list of all plans associated * with a subscription along with their start and end dates. This list contains the * subscription's initial plan along with past and future plan changes. */ fun fetchSchedule( - params: SubscriptionFetchScheduleParams + subscriptionId: String ): CompletableFuture = - fetchSchedule(params, RequestOptions.none()) + fetchSchedule(subscriptionId, SubscriptionFetchScheduleParams.none()) + + /** @see [fetchSchedule] */ + fun fetchSchedule( + subscriptionId: String, + params: SubscriptionFetchScheduleParams = SubscriptionFetchScheduleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetchSchedule(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchSchedule] */ + fun fetchSchedule( + subscriptionId: String, + params: SubscriptionFetchScheduleParams = SubscriptionFetchScheduleParams.none(), + ): CompletableFuture = + fetchSchedule(subscriptionId, params, RequestOptions.none()) /** @see [fetchSchedule] */ fun fetchSchedule( @@ -453,6 +559,19 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetchSchedule] */ + fun fetchSchedule( + params: SubscriptionFetchScheduleParams + ): CompletableFuture = + fetchSchedule(params, RequestOptions.none()) + + /** @see [fetchSchedule] */ + fun fetchSchedule( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + fetchSchedule(subscriptionId, SubscriptionFetchScheduleParams.none(), requestOptions) + /** * This endpoint is used to fetch a subscription's usage in Orb. Especially when combined with * optional query parameters, this endpoint is a powerful way to build visualizations on top of @@ -630,8 +749,23 @@ interface SubscriptionServiceAsync { * - `second_dimension_key`: `provider` * - `second_dimension_value`: `aws` */ - fun fetchUsage(params: SubscriptionFetchUsageParams): CompletableFuture = - fetchUsage(params, RequestOptions.none()) + fun fetchUsage(subscriptionId: String): CompletableFuture = + fetchUsage(subscriptionId, SubscriptionFetchUsageParams.none()) + + /** @see [fetchUsage] */ + fun fetchUsage( + subscriptionId: String, + params: SubscriptionFetchUsageParams = SubscriptionFetchUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetchUsage(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchUsage] */ + fun fetchUsage( + subscriptionId: String, + params: SubscriptionFetchUsageParams = SubscriptionFetchUsageParams.none(), + ): CompletableFuture = + fetchUsage(subscriptionId, params, RequestOptions.none()) /** @see [fetchUsage] */ fun fetchUsage( @@ -639,6 +773,17 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetchUsage] */ + fun fetchUsage(params: SubscriptionFetchUsageParams): CompletableFuture = + fetchUsage(params, RequestOptions.none()) + + /** @see [fetchUsage] */ + fun fetchUsage( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + fetchUsage(subscriptionId, SubscriptionFetchUsageParams.none(), requestOptions) + /** * This endpoint is used to add and edit subscription * [price intervals](/api-reference/price-interval/add-or-edit-price-intervals). By making @@ -707,9 +852,24 @@ interface SubscriptionServiceAsync { * intervals. */ fun priceIntervals( - params: SubscriptionPriceIntervalsParams + subscriptionId: String ): CompletableFuture = - priceIntervals(params, RequestOptions.none()) + priceIntervals(subscriptionId, SubscriptionPriceIntervalsParams.none()) + + /** @see [priceIntervals] */ + fun priceIntervals( + subscriptionId: String, + params: SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + priceIntervals(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [priceIntervals] */ + fun priceIntervals( + subscriptionId: String, + params: SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams.none(), + ): CompletableFuture = + priceIntervals(subscriptionId, params, RequestOptions.none()) /** @see [priceIntervals] */ fun priceIntervals( @@ -717,6 +877,19 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [priceIntervals] */ + fun priceIntervals( + params: SubscriptionPriceIntervalsParams + ): CompletableFuture = + priceIntervals(params, RequestOptions.none()) + + /** @see [priceIntervals] */ + fun priceIntervals( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + priceIntervals(subscriptionId, SubscriptionPriceIntervalsParams.none(), requestOptions) + /** * This endpoint can be used to change an existing subscription's plan. It returns the * serialized updated subscription object. @@ -883,6 +1056,24 @@ interface SubscriptionServiceAsync { * change, adjusting the customer balance as needed. For details on this behavior, see * [Modifying subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). */ + fun schedulePlanChange( + subscriptionId: String, + params: SubscriptionSchedulePlanChangeParams, + ): CompletableFuture = + schedulePlanChange(subscriptionId, params, RequestOptions.none()) + + /** @see [schedulePlanChange] */ + fun schedulePlanChange( + subscriptionId: String, + params: SubscriptionSchedulePlanChangeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + schedulePlanChange( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [schedulePlanChange] */ fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams ): CompletableFuture = @@ -897,10 +1088,23 @@ interface SubscriptionServiceAsync { /** * Manually trigger a phase, effective the given date (or the current time, if not specified). */ + fun triggerPhase(subscriptionId: String): CompletableFuture = + triggerPhase(subscriptionId, SubscriptionTriggerPhaseParams.none()) + + /** @see [triggerPhase] */ fun triggerPhase( - params: SubscriptionTriggerPhaseParams + subscriptionId: String, + params: SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = - triggerPhase(params, RequestOptions.none()) + triggerPhase(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [triggerPhase] */ + fun triggerPhase( + subscriptionId: String, + params: SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams.none(), + ): CompletableFuture = + triggerPhase(subscriptionId, params, RequestOptions.none()) /** @see [triggerPhase] */ fun triggerPhase( @@ -908,6 +1112,19 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [triggerPhase] */ + fun triggerPhase( + params: SubscriptionTriggerPhaseParams + ): CompletableFuture = + triggerPhase(params, RequestOptions.none()) + + /** @see [triggerPhase] */ + fun triggerPhase( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + triggerPhase(subscriptionId, SubscriptionTriggerPhaseParams.none(), requestOptions) + /** * This endpoint can be used to unschedule any pending cancellations for a subscription. * @@ -916,9 +1133,29 @@ interface SubscriptionServiceAsync { * currently scheduled cancellation time. */ fun unscheduleCancellation( - params: SubscriptionUnscheduleCancellationParams + subscriptionId: String ): CompletableFuture = - unscheduleCancellation(params, RequestOptions.none()) + unscheduleCancellation(subscriptionId, SubscriptionUnscheduleCancellationParams.none()) + + /** @see [unscheduleCancellation] */ + fun unscheduleCancellation( + subscriptionId: String, + params: SubscriptionUnscheduleCancellationParams = + SubscriptionUnscheduleCancellationParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + unscheduleCancellation( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unscheduleCancellation] */ + fun unscheduleCancellation( + subscriptionId: String, + params: SubscriptionUnscheduleCancellationParams = + SubscriptionUnscheduleCancellationParams.none(), + ): CompletableFuture = + unscheduleCancellation(subscriptionId, params, RequestOptions.none()) /** @see [unscheduleCancellation] */ fun unscheduleCancellation( @@ -926,12 +1163,47 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [unscheduleCancellation] */ + fun unscheduleCancellation( + params: SubscriptionUnscheduleCancellationParams + ): CompletableFuture = + unscheduleCancellation(params, RequestOptions.none()) + + /** @see [unscheduleCancellation] */ + fun unscheduleCancellation( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + unscheduleCancellation( + subscriptionId, + SubscriptionUnscheduleCancellationParams.none(), + requestOptions, + ) + /** * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. * * If there are no updates scheduled, a request validation error will be returned with a 400 * status code. */ + fun unscheduleFixedFeeQuantityUpdates( + subscriptionId: String, + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + ): CompletableFuture = + unscheduleFixedFeeQuantityUpdates(subscriptionId, params, RequestOptions.none()) + + /** @see [unscheduleFixedFeeQuantityUpdates] */ + fun unscheduleFixedFeeQuantityUpdates( + subscriptionId: String, + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + unscheduleFixedFeeQuantityUpdates( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unscheduleFixedFeeQuantityUpdates] */ fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams ): CompletableFuture = @@ -947,9 +1219,32 @@ interface SubscriptionServiceAsync { * This endpoint can be used to unschedule any pending plan changes on an existing subscription. */ fun unschedulePendingPlanChanges( - params: SubscriptionUnschedulePendingPlanChangesParams + subscriptionId: String ): CompletableFuture = - unschedulePendingPlanChanges(params, RequestOptions.none()) + unschedulePendingPlanChanges( + subscriptionId, + SubscriptionUnschedulePendingPlanChangesParams.none(), + ) + + /** @see [unschedulePendingPlanChanges] */ + fun unschedulePendingPlanChanges( + subscriptionId: String, + params: SubscriptionUnschedulePendingPlanChangesParams = + SubscriptionUnschedulePendingPlanChangesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + unschedulePendingPlanChanges( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unschedulePendingPlanChanges] */ + fun unschedulePendingPlanChanges( + subscriptionId: String, + params: SubscriptionUnschedulePendingPlanChangesParams = + SubscriptionUnschedulePendingPlanChangesParams.none(), + ): CompletableFuture = + unschedulePendingPlanChanges(subscriptionId, params, RequestOptions.none()) /** @see [unschedulePendingPlanChanges] */ fun unschedulePendingPlanChanges( @@ -957,6 +1252,23 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [unschedulePendingPlanChanges] */ + fun unschedulePendingPlanChanges( + params: SubscriptionUnschedulePendingPlanChangesParams + ): CompletableFuture = + unschedulePendingPlanChanges(params, RequestOptions.none()) + + /** @see [unschedulePendingPlanChanges] */ + fun unschedulePendingPlanChanges( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + unschedulePendingPlanChanges( + subscriptionId, + SubscriptionUnschedulePendingPlanChangesParams.none(), + requestOptions, + ) + /** * This endpoint can be used to update the quantity for a fixed fee. * @@ -971,6 +1283,24 @@ interface SubscriptionServiceAsync { * If the fee is an in-advance fixed fee, it will also issue an immediate invoice for the * difference for the remainder of the billing period. */ + fun updateFixedFeeQuantity( + subscriptionId: String, + params: SubscriptionUpdateFixedFeeQuantityParams, + ): CompletableFuture = + updateFixedFeeQuantity(subscriptionId, params, RequestOptions.none()) + + /** @see [updateFixedFeeQuantity] */ + fun updateFixedFeeQuantity( + subscriptionId: String, + params: SubscriptionUpdateFixedFeeQuantityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + updateFixedFeeQuantity( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [updateFixedFeeQuantity] */ fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams ): CompletableFuture = @@ -1000,6 +1330,21 @@ interface SubscriptionServiceAsync { * scheduled or an add-on price was added, that change will be pushed back by the same amount of * time the trial is extended). */ + fun updateTrial( + subscriptionId: String, + params: SubscriptionUpdateTrialParams, + ): CompletableFuture = + updateTrial(subscriptionId, params, RequestOptions.none()) + + /** @see [updateTrial] */ + fun updateTrial( + subscriptionId: String, + params: SubscriptionUpdateTrialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + updateTrial(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [updateTrial] */ fun updateTrial( params: SubscriptionUpdateTrialParams ): CompletableFuture = @@ -1051,9 +1396,25 @@ interface SubscriptionServiceAsync { * the same as [SubscriptionServiceAsync.update]. */ @MustBeClosed + fun update(subscriptionId: String): CompletableFuture> = + update(subscriptionId, SubscriptionUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: SubscriptionUpdateParams - ): CompletableFuture> = update(params, RequestOptions.none()) + subscriptionId: String, + params: SubscriptionUpdateParams = SubscriptionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + subscriptionId: String, + params: SubscriptionUpdateParams = SubscriptionUpdateParams.none(), + ): CompletableFuture> = + update(subscriptionId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -1062,6 +1423,20 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: SubscriptionUpdateParams + ): CompletableFuture> = update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(subscriptionId, SubscriptionUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /subscriptions`, but is otherwise the same as * [SubscriptionServiceAsync.list]. @@ -1096,6 +1471,23 @@ interface SubscriptionServiceAsync { * otherwise the same as [SubscriptionServiceAsync.cancel]. */ @MustBeClosed + fun cancel( + subscriptionId: String, + params: SubscriptionCancelParams, + ): CompletableFuture> = + cancel(subscriptionId, params, RequestOptions.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + subscriptionId: String, + params: SubscriptionCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [cancel] */ + @MustBeClosed fun cancel( params: SubscriptionCancelParams ): CompletableFuture> = @@ -1113,9 +1505,25 @@ interface SubscriptionServiceAsync { * the same as [SubscriptionServiceAsync.fetch]. */ @MustBeClosed + fun fetch(subscriptionId: String): CompletableFuture> = + fetch(subscriptionId, SubscriptionFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed fun fetch( - params: SubscriptionFetchParams - ): CompletableFuture> = fetch(params, RequestOptions.none()) + subscriptionId: String, + params: SubscriptionFetchParams = SubscriptionFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + subscriptionId: String, + params: SubscriptionFetchParams = SubscriptionFetchParams.none(), + ): CompletableFuture> = + fetch(subscriptionId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -1124,15 +1532,46 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [fetch] */ + @MustBeClosed + fun fetch( + params: SubscriptionFetchParams + ): CompletableFuture> = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(subscriptionId, SubscriptionFetchParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/costs`, but is * otherwise the same as [SubscriptionServiceAsync.fetchCosts]. */ @MustBeClosed fun fetchCosts( - params: SubscriptionFetchCostsParams + subscriptionId: String ): CompletableFuture> = - fetchCosts(params, RequestOptions.none()) + fetchCosts(subscriptionId, SubscriptionFetchCostsParams.none()) + + /** @see [fetchCosts] */ + @MustBeClosed + fun fetchCosts( + subscriptionId: String, + params: SubscriptionFetchCostsParams = SubscriptionFetchCostsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetchCosts(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchCosts] */ + @MustBeClosed + fun fetchCosts( + subscriptionId: String, + params: SubscriptionFetchCostsParams = SubscriptionFetchCostsParams.none(), + ): CompletableFuture> = + fetchCosts(subscriptionId, params, RequestOptions.none()) /** @see [fetchCosts] */ @MustBeClosed @@ -1141,15 +1580,47 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [fetchCosts] */ + @MustBeClosed + fun fetchCosts( + params: SubscriptionFetchCostsParams + ): CompletableFuture> = + fetchCosts(params, RequestOptions.none()) + + /** @see [fetchCosts] */ + @MustBeClosed + fun fetchCosts( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetchCosts(subscriptionId, SubscriptionFetchCostsParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/schedule`, but is * otherwise the same as [SubscriptionServiceAsync.fetchSchedule]. */ @MustBeClosed fun fetchSchedule( - params: SubscriptionFetchScheduleParams + subscriptionId: String ): CompletableFuture> = - fetchSchedule(params, RequestOptions.none()) + fetchSchedule(subscriptionId, SubscriptionFetchScheduleParams.none()) + + /** @see [fetchSchedule] */ + @MustBeClosed + fun fetchSchedule( + subscriptionId: String, + params: SubscriptionFetchScheduleParams = SubscriptionFetchScheduleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetchSchedule(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchSchedule] */ + @MustBeClosed + fun fetchSchedule( + subscriptionId: String, + params: SubscriptionFetchScheduleParams = SubscriptionFetchScheduleParams.none(), + ): CompletableFuture> = + fetchSchedule(subscriptionId, params, RequestOptions.none()) /** @see [fetchSchedule] */ @MustBeClosed @@ -1158,15 +1629,47 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [fetchSchedule] */ + @MustBeClosed + fun fetchSchedule( + params: SubscriptionFetchScheduleParams + ): CompletableFuture> = + fetchSchedule(params, RequestOptions.none()) + + /** @see [fetchSchedule] */ + @MustBeClosed + fun fetchSchedule( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetchSchedule(subscriptionId, SubscriptionFetchScheduleParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/usage`, but is * otherwise the same as [SubscriptionServiceAsync.fetchUsage]. */ @MustBeClosed fun fetchUsage( - params: SubscriptionFetchUsageParams + subscriptionId: String ): CompletableFuture> = - fetchUsage(params, RequestOptions.none()) + fetchUsage(subscriptionId, SubscriptionFetchUsageParams.none()) + + /** @see [fetchUsage] */ + @MustBeClosed + fun fetchUsage( + subscriptionId: String, + params: SubscriptionFetchUsageParams = SubscriptionFetchUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetchUsage(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchUsage] */ + @MustBeClosed + fun fetchUsage( + subscriptionId: String, + params: SubscriptionFetchUsageParams = SubscriptionFetchUsageParams.none(), + ): CompletableFuture> = + fetchUsage(subscriptionId, params, RequestOptions.none()) /** @see [fetchUsage] */ @MustBeClosed @@ -1175,15 +1678,50 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [fetchUsage] */ + @MustBeClosed + fun fetchUsage( + params: SubscriptionFetchUsageParams + ): CompletableFuture> = + fetchUsage(params, RequestOptions.none()) + + /** @see [fetchUsage] */ + @MustBeClosed + fun fetchUsage( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetchUsage(subscriptionId, SubscriptionFetchUsageParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/price_intervals`, * but is otherwise the same as [SubscriptionServiceAsync.priceIntervals]. */ @MustBeClosed fun priceIntervals( - params: SubscriptionPriceIntervalsParams + subscriptionId: String ): CompletableFuture> = - priceIntervals(params, RequestOptions.none()) + priceIntervals(subscriptionId, SubscriptionPriceIntervalsParams.none()) + + /** @see [priceIntervals] */ + @MustBeClosed + fun priceIntervals( + subscriptionId: String, + params: SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + priceIntervals( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [priceIntervals] */ + @MustBeClosed + fun priceIntervals( + subscriptionId: String, + params: SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams.none(), + ): CompletableFuture> = + priceIntervals(subscriptionId, params, RequestOptions.none()) /** @see [priceIntervals] */ @MustBeClosed @@ -1192,12 +1730,47 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [priceIntervals] */ + @MustBeClosed + fun priceIntervals( + params: SubscriptionPriceIntervalsParams + ): CompletableFuture> = + priceIntervals(params, RequestOptions.none()) + + /** @see [priceIntervals] */ + @MustBeClosed + fun priceIntervals( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + priceIntervals(subscriptionId, SubscriptionPriceIntervalsParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /subscriptions/{subscription_id}/schedule_plan_change`, but is otherwise the same as * [SubscriptionServiceAsync.schedulePlanChange]. */ @MustBeClosed + fun schedulePlanChange( + subscriptionId: String, + params: SubscriptionSchedulePlanChangeParams, + ): CompletableFuture> = + schedulePlanChange(subscriptionId, params, RequestOptions.none()) + + /** @see [schedulePlanChange] */ + @MustBeClosed + fun schedulePlanChange( + subscriptionId: String, + params: SubscriptionSchedulePlanChangeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + schedulePlanChange( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [schedulePlanChange] */ + @MustBeClosed fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams ): CompletableFuture> = @@ -1216,9 +1789,26 @@ interface SubscriptionServiceAsync { */ @MustBeClosed fun triggerPhase( - params: SubscriptionTriggerPhaseParams + subscriptionId: String ): CompletableFuture> = - triggerPhase(params, RequestOptions.none()) + triggerPhase(subscriptionId, SubscriptionTriggerPhaseParams.none()) + + /** @see [triggerPhase] */ + @MustBeClosed + fun triggerPhase( + subscriptionId: String, + params: SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + triggerPhase(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [triggerPhase] */ + @MustBeClosed + fun triggerPhase( + subscriptionId: String, + params: SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams.none(), + ): CompletableFuture> = + triggerPhase(subscriptionId, params, RequestOptions.none()) /** @see [triggerPhase] */ @MustBeClosed @@ -1227,6 +1817,21 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [triggerPhase] */ + @MustBeClosed + fun triggerPhase( + params: SubscriptionTriggerPhaseParams + ): CompletableFuture> = + triggerPhase(params, RequestOptions.none()) + + /** @see [triggerPhase] */ + @MustBeClosed + fun triggerPhase( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + triggerPhase(subscriptionId, SubscriptionTriggerPhaseParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /subscriptions/{subscription_id}/unschedule_cancellation`, but is otherwise the same as @@ -1234,9 +1839,31 @@ interface SubscriptionServiceAsync { */ @MustBeClosed fun unscheduleCancellation( - params: SubscriptionUnscheduleCancellationParams + subscriptionId: String ): CompletableFuture> = - unscheduleCancellation(params, RequestOptions.none()) + unscheduleCancellation(subscriptionId, SubscriptionUnscheduleCancellationParams.none()) + + /** @see [unscheduleCancellation] */ + @MustBeClosed + fun unscheduleCancellation( + subscriptionId: String, + params: SubscriptionUnscheduleCancellationParams = + SubscriptionUnscheduleCancellationParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + unscheduleCancellation( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unscheduleCancellation] */ + @MustBeClosed + fun unscheduleCancellation( + subscriptionId: String, + params: SubscriptionUnscheduleCancellationParams = + SubscriptionUnscheduleCancellationParams.none(), + ): CompletableFuture> = + unscheduleCancellation(subscriptionId, params, RequestOptions.none()) /** @see [unscheduleCancellation] */ @MustBeClosed @@ -1245,12 +1872,54 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [unscheduleCancellation] */ + @MustBeClosed + fun unscheduleCancellation( + params: SubscriptionUnscheduleCancellationParams + ): CompletableFuture> = + unscheduleCancellation(params, RequestOptions.none()) + + /** @see [unscheduleCancellation] */ + @MustBeClosed + fun unscheduleCancellation( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + unscheduleCancellation( + subscriptionId, + SubscriptionUnscheduleCancellationParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `post * /subscriptions/{subscription_id}/unschedule_fixed_fee_quantity_updates`, but is otherwise * the same as [SubscriptionServiceAsync.unscheduleFixedFeeQuantityUpdates]. */ @MustBeClosed + fun unscheduleFixedFeeQuantityUpdates( + subscriptionId: String, + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + ): CompletableFuture< + HttpResponseFor + > = unscheduleFixedFeeQuantityUpdates(subscriptionId, params, RequestOptions.none()) + + /** @see [unscheduleFixedFeeQuantityUpdates] */ + @MustBeClosed + fun unscheduleFixedFeeQuantityUpdates( + subscriptionId: String, + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture< + HttpResponseFor + > = + unscheduleFixedFeeQuantityUpdates( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unscheduleFixedFeeQuantityUpdates] */ + @MustBeClosed fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams ): CompletableFuture< @@ -1271,9 +1940,34 @@ interface SubscriptionServiceAsync { */ @MustBeClosed fun unschedulePendingPlanChanges( - params: SubscriptionUnschedulePendingPlanChangesParams + subscriptionId: String ): CompletableFuture> = - unschedulePendingPlanChanges(params, RequestOptions.none()) + unschedulePendingPlanChanges( + subscriptionId, + SubscriptionUnschedulePendingPlanChangesParams.none(), + ) + + /** @see [unschedulePendingPlanChanges] */ + @MustBeClosed + fun unschedulePendingPlanChanges( + subscriptionId: String, + params: SubscriptionUnschedulePendingPlanChangesParams = + SubscriptionUnschedulePendingPlanChangesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + unschedulePendingPlanChanges( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unschedulePendingPlanChanges] */ + @MustBeClosed + fun unschedulePendingPlanChanges( + subscriptionId: String, + params: SubscriptionUnschedulePendingPlanChangesParams = + SubscriptionUnschedulePendingPlanChangesParams.none(), + ): CompletableFuture> = + unschedulePendingPlanChanges(subscriptionId, params, RequestOptions.none()) /** @see [unschedulePendingPlanChanges] */ @MustBeClosed @@ -1282,12 +1976,51 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [unschedulePendingPlanChanges] */ + @MustBeClosed + fun unschedulePendingPlanChanges( + params: SubscriptionUnschedulePendingPlanChangesParams + ): CompletableFuture> = + unschedulePendingPlanChanges(params, RequestOptions.none()) + + /** @see [unschedulePendingPlanChanges] */ + @MustBeClosed + fun unschedulePendingPlanChanges( + subscriptionId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + unschedulePendingPlanChanges( + subscriptionId, + SubscriptionUnschedulePendingPlanChangesParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `post * /subscriptions/{subscription_id}/update_fixed_fee_quantity`, but is otherwise the same as * [SubscriptionServiceAsync.updateFixedFeeQuantity]. */ @MustBeClosed + fun updateFixedFeeQuantity( + subscriptionId: String, + params: SubscriptionUpdateFixedFeeQuantityParams, + ): CompletableFuture> = + updateFixedFeeQuantity(subscriptionId, params, RequestOptions.none()) + + /** @see [updateFixedFeeQuantity] */ + @MustBeClosed + fun updateFixedFeeQuantity( + subscriptionId: String, + params: SubscriptionUpdateFixedFeeQuantityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + updateFixedFeeQuantity( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [updateFixedFeeQuantity] */ + @MustBeClosed fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams ): CompletableFuture> = @@ -1305,6 +2038,23 @@ interface SubscriptionServiceAsync { * is otherwise the same as [SubscriptionServiceAsync.updateTrial]. */ @MustBeClosed + fun updateTrial( + subscriptionId: String, + params: SubscriptionUpdateTrialParams, + ): CompletableFuture> = + updateTrial(subscriptionId, params, RequestOptions.none()) + + /** @see [updateTrial] */ + @MustBeClosed + fun updateTrial( + subscriptionId: String, + params: SubscriptionUpdateTrialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + updateTrial(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [updateTrial] */ + @MustBeClosed fun updateTrial( params: SubscriptionUpdateTrialParams ): CompletableFuture> = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt index add175fc..4911183c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/SubscriptionServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -49,6 +50,7 @@ import com.withorb.api.models.SubscriptionUpdateTrialResponse import com.withorb.api.models.SubscriptionUsage import com.withorb.api.models.Subscriptions import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class SubscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionServiceAsync { @@ -218,6 +220,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -269,6 +274,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption .let { SubscriptionListPageAsync.builder() .service(SubscriptionServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -285,6 +291,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionCancelParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -315,6 +324,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -345,6 +357,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionFetchCostsParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -375,6 +390,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionFetchScheduleParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -396,6 +414,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption .let { SubscriptionFetchSchedulePageAsync.builder() .service(SubscriptionServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -411,6 +430,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionFetchUsageParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -441,6 +463,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionPriceIntervalsParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -472,6 +497,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionSchedulePlanChangeParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -503,6 +531,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionTriggerPhaseParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -535,6 +566,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionUnscheduleCancellationParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -575,6 +609,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption ): CompletableFuture< HttpResponseFor > { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -611,6 +648,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionUnschedulePendingPlanChangesParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -647,6 +687,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionUpdateFixedFeeQuantityParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -682,6 +725,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt index 751bbd3c..1d03382a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsync.kt @@ -22,9 +22,23 @@ interface SubscriptionServiceAsync { * subscription. For a full discussion of the subscription resource, see * [Subscription](/core-concepts#subscription). */ + fun list(couponId: String): CompletableFuture = + list(couponId, CouponSubscriptionListParams.none()) + + /** @see [list] */ fun list( - params: CouponSubscriptionListParams - ): CompletableFuture = list(params, RequestOptions.none()) + couponId: String, + params: CouponSubscriptionListParams = CouponSubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [list] */ + fun list( + couponId: String, + params: CouponSubscriptionListParams = CouponSubscriptionListParams.none(), + ): CompletableFuture = + list(couponId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -32,6 +46,18 @@ interface SubscriptionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [list] */ + fun list( + params: CouponSubscriptionListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + couponId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(couponId, CouponSubscriptionListParams.none(), requestOptions) + /** * A view of [SubscriptionServiceAsync] that provides access to raw HTTP responses for each * method. @@ -44,9 +70,26 @@ interface SubscriptionServiceAsync { */ @MustBeClosed fun list( - params: CouponSubscriptionListParams + couponId: String ): CompletableFuture> = - list(params, RequestOptions.none()) + list(couponId, CouponSubscriptionListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + couponId: String, + params: CouponSubscriptionListParams = CouponSubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + couponId: String, + params: CouponSubscriptionListParams = CouponSubscriptionListParams.none(), + ): CompletableFuture> = + list(couponId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -54,5 +97,20 @@ interface SubscriptionServiceAsync { params: CouponSubscriptionListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: CouponSubscriptionListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + couponId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(couponId, CouponSubscriptionListParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt index f749a531..0374a852 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.coupons import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -18,6 +19,7 @@ import com.withorb.api.models.CouponSubscriptionListPageAsync import com.withorb.api.models.CouponSubscriptionListParams import com.withorb.api.models.Subscriptions import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class SubscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionServiceAsync { @@ -47,6 +49,9 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption params: CouponSubscriptionListParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("couponId", params.couponId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -68,6 +73,7 @@ class SubscriptionServiceAsyncImpl internal constructor(private val clientOption .let { CouponSubscriptionListPageAsync.builder() .service(SubscriptionServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt index 7cbf4b6a..482b9d44 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsync.kt @@ -22,6 +22,21 @@ interface BalanceTransactionServiceAsync { * Creates an immutable balance transaction that updates the customer's balance and returns back * the newly created transaction. */ + fun create( + customerId: String, + params: CustomerBalanceTransactionCreateParams, + ): CompletableFuture = + create(customerId, params, RequestOptions.none()) + + /** @see [create] */ + fun create( + customerId: String, + params: CustomerBalanceTransactionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [create] */ fun create( params: CustomerBalanceTransactionCreateParams ): CompletableFuture = @@ -60,10 +75,23 @@ interface BalanceTransactionServiceAsync { * synced to a separate invoicing provider. If a payment gateway such as Stripe is used, the * balance will be applied to the invoice before forwarding payment to the gateway. */ + fun list(customerId: String): CompletableFuture = + list(customerId, CustomerBalanceTransactionListParams.none()) + + /** @see [list] */ fun list( - params: CustomerBalanceTransactionListParams + customerId: String, + params: CustomerBalanceTransactionListParams = CustomerBalanceTransactionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = - list(params, RequestOptions.none()) + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerBalanceTransactionListParams = CustomerBalanceTransactionListParams.none(), + ): CompletableFuture = + list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -71,6 +99,19 @@ interface BalanceTransactionServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [list] */ + fun list( + params: CustomerBalanceTransactionListParams + ): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(customerId, CustomerBalanceTransactionListParams.none(), requestOptions) + /** * A view of [BalanceTransactionServiceAsync] that provides access to raw HTTP responses for * each method. @@ -82,6 +123,23 @@ interface BalanceTransactionServiceAsync { * is otherwise the same as [BalanceTransactionServiceAsync.create]. */ @MustBeClosed + fun create( + customerId: String, + params: CustomerBalanceTransactionCreateParams, + ): CompletableFuture> = + create(customerId, params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + customerId: String, + params: CustomerBalanceTransactionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed fun create( params: CustomerBalanceTransactionCreateParams ): CompletableFuture> = @@ -100,9 +158,28 @@ interface BalanceTransactionServiceAsync { */ @MustBeClosed fun list( - params: CustomerBalanceTransactionListParams + customerId: String ): CompletableFuture> = - list(params, RequestOptions.none()) + list(customerId, CustomerBalanceTransactionListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerBalanceTransactionListParams = + CustomerBalanceTransactionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerBalanceTransactionListParams = + CustomerBalanceTransactionListParams.none(), + ): CompletableFuture> = + list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -110,5 +187,20 @@ interface BalanceTransactionServiceAsync { params: CustomerBalanceTransactionListParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [list] */ + @MustBeClosed + fun list( + params: CustomerBalanceTransactionListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(customerId, CustomerBalanceTransactionListParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt index b2c2284d..817135f9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.customers import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -21,6 +22,7 @@ import com.withorb.api.models.CustomerBalanceTransactionListPageAsync import com.withorb.api.models.CustomerBalanceTransactionListPageResponse import com.withorb.api.models.CustomerBalanceTransactionListParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class BalanceTransactionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionServiceAsync { @@ -58,6 +60,9 @@ internal constructor(private val clientOptions: ClientOptions) : BalanceTransact params: CustomerBalanceTransactionCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -89,6 +94,9 @@ internal constructor(private val clientOptions: ClientOptions) : BalanceTransact params: CustomerBalanceTransactionListParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -110,6 +118,7 @@ internal constructor(private val clientOptions: ClientOptions) : BalanceTransact .let { CustomerBalanceTransactionListPageAsync.builder() .service(BalanceTransactionServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() 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 1474003b..945da63d 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 @@ -128,8 +128,22 @@ interface CostServiceAsync { * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and * `secondary_grouping_value` available. */ - fun list(params: CustomerCostListParams): CompletableFuture = - list(params, RequestOptions.none()) + fun list(customerId: String): CompletableFuture = + list(customerId, CustomerCostListParams.none()) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCostListParams = CustomerCostListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCostListParams = CustomerCostListParams.none(), + ): CompletableFuture = list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -137,6 +151,17 @@ interface CostServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [list] */ + fun list(params: CustomerCostListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(customerId, CustomerCostListParams.none(), requestOptions) + /** * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated * by applying pricing information to the underlying usage (see the @@ -248,9 +273,27 @@ interface CostServiceAsync { * `secondary_grouping_value` available. */ fun listByExternalId( - params: CustomerCostListByExternalIdParams + externalCustomerId: String ): CompletableFuture = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCostListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCostListByExternalIdParams = CustomerCostListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCostListByExternalIdParams = CustomerCostListByExternalIdParams.none(), + ): CompletableFuture = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ fun listByExternalId( @@ -258,6 +301,23 @@ interface CostServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [listByExternalId] */ + fun listByExternalId( + params: CustomerCostListByExternalIdParams + ): CompletableFuture = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listByExternalId( + externalCustomerId, + CustomerCostListByExternalIdParams.none(), + requestOptions, + ) + /** A view of [CostServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -266,10 +326,25 @@ interface CostServiceAsync { * the same as [CostServiceAsync.list]. */ @MustBeClosed + fun list(customerId: String): CompletableFuture> = + list(customerId, CustomerCostListParams.none()) + + /** @see [list] */ + @MustBeClosed fun list( - params: CustomerCostListParams + customerId: String, + params: CustomerCostListParams = CustomerCostListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - list(params, RequestOptions.none()) + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCostListParams = CustomerCostListParams.none(), + ): CompletableFuture> = + list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -278,6 +353,21 @@ interface CostServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [list] */ + @MustBeClosed + fun list( + params: CustomerCostListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(customerId, CustomerCostListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get * /customers/external_customer_id/{external_customer_id}/costs`, but is otherwise the same @@ -285,9 +375,29 @@ interface CostServiceAsync { */ @MustBeClosed fun listByExternalId( - params: CustomerCostListByExternalIdParams + externalCustomerId: String ): CompletableFuture> = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCostListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCostListByExternalIdParams = CustomerCostListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCostListByExternalIdParams = CustomerCostListByExternalIdParams.none(), + ): CompletableFuture> = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ @MustBeClosed @@ -295,5 +405,24 @@ interface CostServiceAsync { params: CustomerCostListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + params: CustomerCostListByExternalIdParams + ): CompletableFuture> = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listByExternalId( + externalCustomerId, + CustomerCostListByExternalIdParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt index 5a17f858..49415184 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CostServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.customers import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -19,6 +20,7 @@ import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams import com.withorb.api.models.CustomerCostListResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CostServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CostServiceAsync { @@ -56,6 +58,9 @@ class CostServiceAsyncImpl internal constructor(private val clientOptions: Clien params: CustomerCostListParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -86,6 +91,9 @@ class CostServiceAsyncImpl internal constructor(private val clientOptions: Clien params: CustomerCostListByExternalIdParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt index a07d73d2..a20d114b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsync.kt @@ -33,8 +33,23 @@ interface CreditServiceAsync { * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. */ - fun list(params: CustomerCreditListParams): CompletableFuture = - list(params, RequestOptions.none()) + fun list(customerId: String): CompletableFuture = + list(customerId, CustomerCreditListParams.none()) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditListParams = CustomerCreditListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditListParams = CustomerCreditListParams.none(), + ): CompletableFuture = + list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -42,6 +57,17 @@ interface CreditServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [list] */ + fun list(params: CustomerCreditListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(customerId, CustomerCreditListParams.none(), requestOptions) + /** * Returns a paginated list of unexpired, non-zero credit blocks for a customer. * @@ -52,9 +78,27 @@ interface CreditServiceAsync { * `currency` to an ISO 4217 string. */ fun listByExternalId( - params: CustomerCreditListByExternalIdParams + externalCustomerId: String ): CompletableFuture = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCreditListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditListByExternalIdParams = CustomerCreditListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditListByExternalIdParams = CustomerCreditListByExternalIdParams.none(), + ): CompletableFuture = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ fun listByExternalId( @@ -62,6 +106,23 @@ interface CreditServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [listByExternalId] */ + fun listByExternalId( + params: CustomerCreditListByExternalIdParams + ): CompletableFuture = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listByExternalId( + externalCustomerId, + CustomerCreditListByExternalIdParams.none(), + requestOptions, + ) + /** * A view of [CreditServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -77,9 +138,26 @@ interface CreditServiceAsync { */ @MustBeClosed fun list( - params: CustomerCreditListParams + customerId: String ): CompletableFuture> = - list(params, RequestOptions.none()) + list(customerId, CustomerCreditListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditListParams = CustomerCreditListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditListParams = CustomerCreditListParams.none(), + ): CompletableFuture> = + list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -88,6 +166,21 @@ interface CreditServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [list] */ + @MustBeClosed + fun list( + params: CustomerCreditListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(customerId, CustomerCreditListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get * /customers/external_customer_id/{external_customer_id}/credits`, but is otherwise the @@ -95,9 +188,31 @@ interface CreditServiceAsync { */ @MustBeClosed fun listByExternalId( - params: CustomerCreditListByExternalIdParams + externalCustomerId: String ): CompletableFuture> = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCreditListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditListByExternalIdParams = + CustomerCreditListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditListByExternalIdParams = + CustomerCreditListByExternalIdParams.none(), + ): CompletableFuture> = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ @MustBeClosed @@ -105,5 +220,24 @@ interface CreditServiceAsync { params: CustomerCreditListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + params: CustomerCreditListByExternalIdParams + ): CompletableFuture> = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listByExternalId( + externalCustomerId, + CustomerCreditListByExternalIdParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt index 39fad882..2e201b33 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.customers import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import com.withorb.api.services.async.customers.credits.LedgerServiceAsyncImpl import com.withorb.api.services.async.customers.credits.TopUpServiceAsync import com.withorb.api.services.async.customers.credits.TopUpServiceAsyncImpl import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class CreditServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CreditServiceAsync { @@ -82,6 +84,9 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CustomerCreditListParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -103,6 +108,7 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli .let { CustomerCreditListPageAsync.builder() .service(CreditServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -119,6 +125,9 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CustomerCreditListByExternalIdParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -145,6 +154,7 @@ class CreditServiceAsyncImpl internal constructor(private val clientOptions: Cli .let { CustomerCreditListByExternalIdPageAsync.builder() .service(CreditServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() 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 3b9bc08a..1c297c33 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 @@ -101,9 +101,23 @@ interface LedgerServiceAsync { * 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. */ + fun list(customerId: String): CompletableFuture = + list(customerId, CustomerCreditLedgerListParams.none()) + + /** @see [list] */ fun list( - params: CustomerCreditLedgerListParams - ): CompletableFuture = list(params, RequestOptions.none()) + customerId: String, + params: CustomerCreditLedgerListParams = CustomerCreditLedgerListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditLedgerListParams = CustomerCreditLedgerListParams.none(), + ): CompletableFuture = + list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -111,6 +125,18 @@ interface LedgerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [list] */ + fun list( + params: CustomerCreditLedgerListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(customerId, CustomerCreditLedgerListParams.none(), requestOptions) + /** * This endpoint allows you to create a new ledger entry for a specified customer's balance. * This can be used to increment balance, deduct credits, and change the expiry date of existing @@ -214,6 +240,21 @@ interface LedgerServiceAsync { * decremented from, and `amount` indicates how many credits to return to the customer, up to * the block's initial balance. */ + fun createEntry( + customerId: String, + params: CustomerCreditLedgerCreateEntryParams, + ): CompletableFuture = + createEntry(customerId, params, RequestOptions.none()) + + /** @see [createEntry] */ + fun createEntry( + customerId: String, + params: CustomerCreditLedgerCreateEntryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + createEntry(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [createEntry] */ fun createEntry( params: CustomerCreditLedgerCreateEntryParams ): CompletableFuture = @@ -328,6 +369,24 @@ interface LedgerServiceAsync { * decremented from, and `amount` indicates how many credits to return to the customer, up to * the block's initial balance. */ + fun createEntryByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + ): CompletableFuture = + createEntryByExternalId(externalCustomerId, params, RequestOptions.none()) + + /** @see [createEntryByExternalId] */ + fun createEntryByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + createEntryByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createEntryByExternalId] */ fun createEntryByExternalId( params: CustomerCreditLedgerCreateEntryByExternalIdParams ): CompletableFuture = @@ -419,9 +478,29 @@ interface LedgerServiceAsync { * be added to the ledger to indicate the adjustment of credits. */ fun listByExternalId( - params: CustomerCreditLedgerListByExternalIdParams + externalCustomerId: String ): CompletableFuture = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCreditLedgerListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerListByExternalIdParams = + CustomerCreditLedgerListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerListByExternalIdParams = + CustomerCreditLedgerListByExternalIdParams.none(), + ): CompletableFuture = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ fun listByExternalId( @@ -429,6 +508,23 @@ interface LedgerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [listByExternalId] */ + fun listByExternalId( + params: CustomerCreditLedgerListByExternalIdParams + ): CompletableFuture = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listByExternalId( + externalCustomerId, + CustomerCreditLedgerListByExternalIdParams.none(), + requestOptions, + ) + /** * A view of [LedgerServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -440,9 +536,26 @@ interface LedgerServiceAsync { */ @MustBeClosed fun list( - params: CustomerCreditLedgerListParams + customerId: String ): CompletableFuture> = - list(params, RequestOptions.none()) + list(customerId, CustomerCreditLedgerListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditLedgerListParams = CustomerCreditLedgerListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditLedgerListParams = CustomerCreditLedgerListParams.none(), + ): CompletableFuture> = + list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -451,11 +564,43 @@ interface LedgerServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [list] */ + @MustBeClosed + fun list( + params: CustomerCreditLedgerListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(customerId, CustomerCreditLedgerListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /customers/{customer_id}/credits/ledger_entry`, but * is otherwise the same as [LedgerServiceAsync.createEntry]. */ @MustBeClosed + fun createEntry( + customerId: String, + params: CustomerCreditLedgerCreateEntryParams, + ): CompletableFuture> = + createEntry(customerId, params, RequestOptions.none()) + + /** @see [createEntry] */ + @MustBeClosed + fun createEntry( + customerId: String, + params: CustomerCreditLedgerCreateEntryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + createEntry(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [createEntry] */ + @MustBeClosed fun createEntry( params: CustomerCreditLedgerCreateEntryParams ): CompletableFuture> = @@ -474,6 +619,26 @@ interface LedgerServiceAsync { * otherwise the same as [LedgerServiceAsync.createEntryByExternalId]. */ @MustBeClosed + fun createEntryByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + ): CompletableFuture> = + createEntryByExternalId(externalCustomerId, params, RequestOptions.none()) + + /** @see [createEntryByExternalId] */ + @MustBeClosed + fun createEntryByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + createEntryByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createEntryByExternalId] */ + @MustBeClosed fun createEntryByExternalId( params: CustomerCreditLedgerCreateEntryByExternalIdParams ): CompletableFuture> = @@ -493,9 +658,31 @@ interface LedgerServiceAsync { */ @MustBeClosed fun listByExternalId( - params: CustomerCreditLedgerListByExternalIdParams + externalCustomerId: String ): CompletableFuture> = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCreditLedgerListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerListByExternalIdParams = + CustomerCreditLedgerListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerListByExternalIdParams = + CustomerCreditLedgerListByExternalIdParams.none(), + ): CompletableFuture> = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ @MustBeClosed @@ -503,5 +690,24 @@ interface LedgerServiceAsync { params: CustomerCreditLedgerListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + params: CustomerCreditLedgerListByExternalIdParams + ): CompletableFuture> = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listByExternalId( + externalCustomerId, + CustomerCreditLedgerListByExternalIdParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt index 111daf6a..f168ea41 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/LedgerServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.customers.credits import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import com.withorb.api.models.CustomerCreditLedgerListPageAsync import com.withorb.api.models.CustomerCreditLedgerListPageResponse import com.withorb.api.models.CustomerCreditLedgerListParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class LedgerServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : LedgerServiceAsync { @@ -77,6 +79,9 @@ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CustomerCreditLedgerListParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -98,6 +103,7 @@ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: Cli .let { CustomerCreditLedgerListPageAsync.builder() .service(LedgerServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -114,6 +120,9 @@ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CustomerCreditLedgerCreateEntryParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -148,6 +157,9 @@ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CustomerCreditLedgerCreateEntryByExternalIdParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -186,6 +198,9 @@ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: Cli params: CustomerCreditLedgerListByExternalIdParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -213,6 +228,7 @@ class LedgerServiceAsyncImpl internal constructor(private val clientOptions: Cli .let { CustomerCreditLedgerListByExternalIdPageAsync.builder() .service(LedgerServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt index 0dce0c98..2b6ec8ca 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsync.kt @@ -33,6 +33,21 @@ interface TopUpServiceAsync { * If a top-up already exists for this customer in the same currency, the existing top-up will * be replaced. */ + fun create( + customerId: String, + params: CustomerCreditTopUpCreateParams, + ): CompletableFuture = + create(customerId, params, RequestOptions.none()) + + /** @see [create] */ + fun create( + customerId: String, + params: CustomerCreditTopUpCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [create] */ fun create( params: CustomerCreditTopUpCreateParams ): CompletableFuture = create(params, RequestOptions.none()) @@ -44,9 +59,23 @@ interface TopUpServiceAsync { ): CompletableFuture /** List top-ups */ + fun list(customerId: String): CompletableFuture = + list(customerId, CustomerCreditTopUpListParams.none()) + + /** @see [list] */ fun list( - params: CustomerCreditTopUpListParams - ): CompletableFuture = list(params, RequestOptions.none()) + customerId: String, + params: CustomerCreditTopUpListParams = CustomerCreditTopUpListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditTopUpListParams = CustomerCreditTopUpListParams.none(), + ): CompletableFuture = + list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -54,10 +83,34 @@ interface TopUpServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [list] */ + fun list( + params: CustomerCreditTopUpListParams + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(customerId, CustomerCreditTopUpListParams.none(), requestOptions) + /** * This deactivates the top-up and voids any invoices associated with pending credit blocks * purchased through the top-up. */ + fun delete(topUpId: String, params: CustomerCreditTopUpDeleteParams): CompletableFuture = + delete(topUpId, params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + topUpId: String, + params: CustomerCreditTopUpDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().topUpId(topUpId).build(), requestOptions) + + /** @see [delete] */ fun delete(params: CustomerCreditTopUpDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) @@ -75,6 +128,24 @@ interface TopUpServiceAsync { * If a top-up already exists for this customer in the same currency, the existing top-up will * be replaced. */ + fun createByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpCreateByExternalIdParams, + ): CompletableFuture = + createByExternalId(externalCustomerId, params, RequestOptions.none()) + + /** @see [createByExternalId] */ + fun createByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpCreateByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + createByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createByExternalId] */ fun createByExternalId( params: CustomerCreditTopUpCreateByExternalIdParams ): CompletableFuture = @@ -90,6 +161,20 @@ interface TopUpServiceAsync { * This deactivates the top-up and voids any invoices associated with pending credit blocks * purchased through the top-up. */ + fun deleteByExternalId( + topUpId: String, + params: CustomerCreditTopUpDeleteByExternalIdParams, + ): CompletableFuture = deleteByExternalId(topUpId, params, RequestOptions.none()) + + /** @see [deleteByExternalId] */ + fun deleteByExternalId( + topUpId: String, + params: CustomerCreditTopUpDeleteByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + deleteByExternalId(params.toBuilder().topUpId(topUpId).build(), requestOptions) + + /** @see [deleteByExternalId] */ fun deleteByExternalId( params: CustomerCreditTopUpDeleteByExternalIdParams ): CompletableFuture = deleteByExternalId(params, RequestOptions.none()) @@ -102,9 +187,29 @@ interface TopUpServiceAsync { /** List top-ups by external ID */ fun listByExternalId( - params: CustomerCreditTopUpListByExternalIdParams + externalCustomerId: String ): CompletableFuture = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCreditTopUpListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpListByExternalIdParams = + CustomerCreditTopUpListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpListByExternalIdParams = + CustomerCreditTopUpListByExternalIdParams.none(), + ): CompletableFuture = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ fun listByExternalId( @@ -112,6 +217,23 @@ interface TopUpServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [listByExternalId] */ + fun listByExternalId( + params: CustomerCreditTopUpListByExternalIdParams + ): CompletableFuture = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listByExternalId( + externalCustomerId, + CustomerCreditTopUpListByExternalIdParams.none(), + requestOptions, + ) + /** A view of [TopUpServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -120,6 +242,23 @@ interface TopUpServiceAsync { * otherwise the same as [TopUpServiceAsync.create]. */ @MustBeClosed + fun create( + customerId: String, + params: CustomerCreditTopUpCreateParams, + ): CompletableFuture> = + create(customerId, params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + customerId: String, + params: CustomerCreditTopUpCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed fun create( params: CustomerCreditTopUpCreateParams ): CompletableFuture> = @@ -138,9 +277,26 @@ interface TopUpServiceAsync { */ @MustBeClosed fun list( - params: CustomerCreditTopUpListParams + customerId: String ): CompletableFuture> = - list(params, RequestOptions.none()) + list(customerId, CustomerCreditTopUpListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditTopUpListParams = CustomerCreditTopUpListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditTopUpListParams = CustomerCreditTopUpListParams.none(), + ): CompletableFuture> = + list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -149,12 +305,43 @@ interface TopUpServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [list] */ + @MustBeClosed + fun list( + params: CustomerCreditTopUpListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(customerId, CustomerCreditTopUpListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete * /customers/{customer_id}/credits/top_ups/{top_up_id}`, but is otherwise the same as * [TopUpServiceAsync.delete]. */ @MustBeClosed + fun delete( + topUpId: String, + params: CustomerCreditTopUpDeleteParams, + ): CompletableFuture = delete(topUpId, params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + topUpId: String, + params: CustomerCreditTopUpDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().topUpId(topUpId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed fun delete(params: CustomerCreditTopUpDeleteParams): CompletableFuture = delete(params, RequestOptions.none()) @@ -171,6 +358,26 @@ interface TopUpServiceAsync { * the same as [TopUpServiceAsync.createByExternalId]. */ @MustBeClosed + fun createByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpCreateByExternalIdParams, + ): CompletableFuture> = + createByExternalId(externalCustomerId, params, RequestOptions.none()) + + /** @see [createByExternalId] */ + @MustBeClosed + fun createByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpCreateByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + createByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createByExternalId] */ + @MustBeClosed fun createByExternalId( params: CustomerCreditTopUpCreateByExternalIdParams ): CompletableFuture> = @@ -189,6 +396,23 @@ interface TopUpServiceAsync { * is otherwise the same as [TopUpServiceAsync.deleteByExternalId]. */ @MustBeClosed + fun deleteByExternalId( + topUpId: String, + params: CustomerCreditTopUpDeleteByExternalIdParams, + ): CompletableFuture = + deleteByExternalId(topUpId, params, RequestOptions.none()) + + /** @see [deleteByExternalId] */ + @MustBeClosed + fun deleteByExternalId( + topUpId: String, + params: CustomerCreditTopUpDeleteByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + deleteByExternalId(params.toBuilder().topUpId(topUpId).build(), requestOptions) + + /** @see [deleteByExternalId] */ + @MustBeClosed fun deleteByExternalId( params: CustomerCreditTopUpDeleteByExternalIdParams ): CompletableFuture = deleteByExternalId(params, RequestOptions.none()) @@ -207,9 +431,31 @@ interface TopUpServiceAsync { */ @MustBeClosed fun listByExternalId( - params: CustomerCreditTopUpListByExternalIdParams + externalCustomerId: String ): CompletableFuture> = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCreditTopUpListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpListByExternalIdParams = + CustomerCreditTopUpListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpListByExternalIdParams = + CustomerCreditTopUpListByExternalIdParams.none(), + ): CompletableFuture> = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ @MustBeClosed @@ -217,5 +463,24 @@ interface TopUpServiceAsync { params: CustomerCreditTopUpListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + params: CustomerCreditTopUpListByExternalIdParams + ): CompletableFuture> = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listByExternalId( + externalCustomerId, + CustomerCreditTopUpListByExternalIdParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt index 09ca2531..b8c3b4fb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.customers.credits import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.emptyHandler import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler @@ -30,6 +31,7 @@ import com.withorb.api.models.CustomerCreditTopUpListPageAsync import com.withorb.api.models.CustomerCreditTopUpListPageResponse import com.withorb.api.models.CustomerCreditTopUpListParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class TopUpServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : TopUpServiceAsync { @@ -95,6 +97,9 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie params: CustomerCreditTopUpCreateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -126,6 +131,9 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie params: CustomerCreditTopUpListParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -147,6 +155,7 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie .let { CustomerCreditTopUpListPageAsync.builder() .service(TopUpServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -161,6 +170,9 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie params: CustomerCreditTopUpDeleteParams, requestOptions: RequestOptions, ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topUpId", params.topUpId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -191,6 +203,9 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie params: CustomerCreditTopUpCreateByExternalIdParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -227,6 +242,9 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie params: CustomerCreditTopUpDeleteByExternalIdParams, requestOptions: RequestOptions, ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topUpId", params.topUpId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -258,6 +276,9 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie params: CustomerCreditTopUpListByExternalIdParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -285,6 +306,7 @@ class TopUpServiceAsyncImpl internal constructor(private val clientOptions: Clie .let { CustomerCreditTopUpListByExternalIdPageAsync.builder() .service(TopUpServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsync.kt index eeb23832..7648ae7d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsync.kt @@ -18,8 +18,35 @@ interface ExternalDimensionalPriceGroupIdServiceAsync { /** Fetch dimensional price group by external ID */ fun retrieve( - params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams - ): CompletableFuture = retrieve(params, RequestOptions.none()) + externalDimensionalPriceGroupId: String + ): CompletableFuture = + retrieve( + externalDimensionalPriceGroupId, + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + ) + + /** @see [retrieve] */ + fun retrieve( + externalDimensionalPriceGroupId: String, + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve( + params + .toBuilder() + .externalDimensionalPriceGroupId(externalDimensionalPriceGroupId) + .build(), + requestOptions, + ) + + /** @see [retrieve] */ + fun retrieve( + externalDimensionalPriceGroupId: String, + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + ): CompletableFuture = + retrieve(externalDimensionalPriceGroupId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -27,6 +54,22 @@ interface ExternalDimensionalPriceGroupIdServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [retrieve] */ + fun retrieve( + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + externalDimensionalPriceGroupId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve( + externalDimensionalPriceGroupId, + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + requestOptions, + ) + /** * A view of [ExternalDimensionalPriceGroupIdServiceAsync] that provides access to raw HTTP * responses for each method. @@ -40,9 +83,37 @@ interface ExternalDimensionalPriceGroupIdServiceAsync { */ @MustBeClosed fun retrieve( - params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams + externalDimensionalPriceGroupId: String ): CompletableFuture> = - retrieve(params, RequestOptions.none()) + retrieve( + externalDimensionalPriceGroupId, + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + ) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + externalDimensionalPriceGroupId: String, + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve( + params + .toBuilder() + .externalDimensionalPriceGroupId(externalDimensionalPriceGroupId) + .build(), + requestOptions, + ) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + externalDimensionalPriceGroupId: String, + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + ): CompletableFuture> = + retrieve(externalDimensionalPriceGroupId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -50,5 +121,24 @@ interface ExternalDimensionalPriceGroupIdServiceAsync { params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + externalDimensionalPriceGroupId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve( + externalDimensionalPriceGroupId, + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncImpl.kt index 811a2580..e7f51a77 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.dimensionalPriceGroups import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -17,6 +18,7 @@ import com.withorb.api.core.prepareAsync import com.withorb.api.models.DimensionalPriceGroup import com.withorb.api.models.DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class ExternalDimensionalPriceGroupIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -51,6 +53,12 @@ internal constructor(private val clientOptions: ClientOptions) : params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired( + "externalDimensionalPriceGroupId", + params.externalDimensionalPriceGroupId().getOrNull(), + ) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 aeace6ac..209e019d 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 @@ -93,8 +93,23 @@ interface BackfillServiceAsync { * asynchronously reflect the updated usage in invoice amounts and usage graphs. Once all of the * updates are complete, the backfill's status will transition to `reflected`. */ - fun close(params: EventBackfillCloseParams): CompletableFuture = - close(params, RequestOptions.none()) + fun close(backfillId: String): CompletableFuture = + close(backfillId, EventBackfillCloseParams.none()) + + /** @see [close] */ + fun close( + backfillId: String, + params: EventBackfillCloseParams = EventBackfillCloseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + close(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [close] */ + fun close( + backfillId: String, + params: EventBackfillCloseParams = EventBackfillCloseParams.none(), + ): CompletableFuture = + close(backfillId, params, RequestOptions.none()) /** @see [close] */ fun close( @@ -102,9 +117,35 @@ interface BackfillServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [close] */ + fun close(params: EventBackfillCloseParams): CompletableFuture = + close(params, RequestOptions.none()) + + /** @see [close] */ + fun close( + backfillId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + close(backfillId, EventBackfillCloseParams.none(), requestOptions) + /** This endpoint is used to fetch a backfill given an identifier. */ - fun fetch(params: EventBackfillFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(backfillId: String): CompletableFuture = + fetch(backfillId, EventBackfillFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + backfillId: String, + params: EventBackfillFetchParams = EventBackfillFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetch(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + backfillId: String, + params: EventBackfillFetchParams = EventBackfillFetchParams.none(), + ): CompletableFuture = + fetch(backfillId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -112,6 +153,17 @@ interface BackfillServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: EventBackfillFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch( + backfillId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + fetch(backfillId, EventBackfillFetchParams.none(), requestOptions) + /** * Reverting a backfill undoes all the effects of closing the backfill. If the backfill is * reflected, the status will transition to `pending_revert` while the effects of the backfill @@ -120,8 +172,23 @@ interface BackfillServiceAsync { * If a backfill is reverted before its closed, no usage will be updated as a result of the * backfill and it will immediately transition to `reverted`. */ - fun revert(params: EventBackfillRevertParams): CompletableFuture = - revert(params, RequestOptions.none()) + fun revert(backfillId: String): CompletableFuture = + revert(backfillId, EventBackfillRevertParams.none()) + + /** @see [revert] */ + fun revert( + backfillId: String, + params: EventBackfillRevertParams = EventBackfillRevertParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + revert(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [revert] */ + fun revert( + backfillId: String, + params: EventBackfillRevertParams = EventBackfillRevertParams.none(), + ): CompletableFuture = + revert(backfillId, params, RequestOptions.none()) /** @see [revert] */ fun revert( @@ -129,6 +196,17 @@ interface BackfillServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [revert] */ + fun revert(params: EventBackfillRevertParams): CompletableFuture = + revert(params, RequestOptions.none()) + + /** @see [revert] */ + fun revert( + backfillId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + revert(backfillId, EventBackfillRevertParams.none(), requestOptions) + /** * A view of [BackfillServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -186,9 +264,26 @@ interface BackfillServiceAsync { */ @MustBeClosed fun close( - params: EventBackfillCloseParams + backfillId: String ): CompletableFuture> = - close(params, RequestOptions.none()) + close(backfillId, EventBackfillCloseParams.none()) + + /** @see [close] */ + @MustBeClosed + fun close( + backfillId: String, + params: EventBackfillCloseParams = EventBackfillCloseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + close(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [close] */ + @MustBeClosed + fun close( + backfillId: String, + params: EventBackfillCloseParams = EventBackfillCloseParams.none(), + ): CompletableFuture> = + close(backfillId, params, RequestOptions.none()) /** @see [close] */ @MustBeClosed @@ -197,15 +292,47 @@ interface BackfillServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [close] */ + @MustBeClosed + fun close( + params: EventBackfillCloseParams + ): CompletableFuture> = + close(params, RequestOptions.none()) + + /** @see [close] */ + @MustBeClosed + fun close( + backfillId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + close(backfillId, EventBackfillCloseParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /events/backfills/{backfill_id}`, but is otherwise * the same as [BackfillServiceAsync.fetch]. */ @MustBeClosed fun fetch( - params: EventBackfillFetchParams + backfillId: String ): CompletableFuture> = - fetch(params, RequestOptions.none()) + fetch(backfillId, EventBackfillFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + backfillId: String, + params: EventBackfillFetchParams = EventBackfillFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + backfillId: String, + params: EventBackfillFetchParams = EventBackfillFetchParams.none(), + ): CompletableFuture> = + fetch(backfillId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -214,15 +341,47 @@ interface BackfillServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [fetch] */ + @MustBeClosed + fun fetch( + params: EventBackfillFetchParams + ): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + backfillId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(backfillId, EventBackfillFetchParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /events/backfills/{backfill_id}/revert`, but is * otherwise the same as [BackfillServiceAsync.revert]. */ @MustBeClosed fun revert( - params: EventBackfillRevertParams + backfillId: String ): CompletableFuture> = - revert(params, RequestOptions.none()) + revert(backfillId, EventBackfillRevertParams.none()) + + /** @see [revert] */ + @MustBeClosed + fun revert( + backfillId: String, + params: EventBackfillRevertParams = EventBackfillRevertParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + revert(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [revert] */ + @MustBeClosed + fun revert( + backfillId: String, + params: EventBackfillRevertParams = EventBackfillRevertParams.none(), + ): CompletableFuture> = + revert(backfillId, params, RequestOptions.none()) /** @see [revert] */ @MustBeClosed @@ -230,5 +389,20 @@ interface BackfillServiceAsync { params: EventBackfillRevertParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [revert] */ + @MustBeClosed + fun revert( + params: EventBackfillRevertParams + ): CompletableFuture> = + revert(params, RequestOptions.none()) + + /** @see [revert] */ + @MustBeClosed + fun revert( + backfillId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + revert(backfillId, EventBackfillRevertParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt index cff62b17..81912bef 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.events import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -27,6 +28,7 @@ import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams import com.withorb.api.models.EventBackfillRevertResponse import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class BackfillServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : BackfillServiceAsync { @@ -137,6 +139,7 @@ class BackfillServiceAsyncImpl internal constructor(private val clientOptions: C .let { EventBackfillListPageAsync.builder() .service(BackfillServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) .params(params) .response(it) .build() @@ -153,6 +156,9 @@ class BackfillServiceAsyncImpl internal constructor(private val clientOptions: C params: EventBackfillCloseParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("backfillId", params.backfillId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -184,6 +190,9 @@ class BackfillServiceAsyncImpl internal constructor(private val clientOptions: C params: EventBackfillFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("backfillId", params.backfillId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -214,6 +223,9 @@ class BackfillServiceAsyncImpl internal constructor(private val clientOptions: C params: EventBackfillRevertParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("backfillId", params.backfillId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) 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 fc671e06..2dc9d70a 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 @@ -23,8 +23,22 @@ interface ExternalPlanIdServiceAsync { * * Other fields on a customer are currently immutable. */ - fun update(params: PlanExternalPlanIdUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(otherExternalPlanId: String): CompletableFuture = + update(otherExternalPlanId, PlanExternalPlanIdUpdateParams.none()) + + /** @see [update] */ + fun update( + otherExternalPlanId: String, + params: PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().otherExternalPlanId(otherExternalPlanId).build(), requestOptions) + + /** @see [update] */ + fun update( + otherExternalPlanId: String, + params: PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams.none(), + ): CompletableFuture = update(otherExternalPlanId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -32,6 +46,17 @@ interface ExternalPlanIdServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: PlanExternalPlanIdUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update( + otherExternalPlanId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(otherExternalPlanId, PlanExternalPlanIdUpdateParams.none(), requestOptions) + /** * This endpoint is used to fetch [plan](/core-concepts##plan-and-price) details given an * external_plan_id identifier. It returns information about the prices included in the plan and @@ -49,8 +74,22 @@ interface ExternalPlanIdServiceAsync { * detailed explanation of price types can be found in the * [Price schema](/core-concepts#plan-and-price). " */ - fun fetch(params: PlanExternalPlanIdFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(externalPlanId: String): CompletableFuture = + fetch(externalPlanId, PlanExternalPlanIdFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + externalPlanId: String, + params: PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetch(params.toBuilder().externalPlanId(externalPlanId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + externalPlanId: String, + params: PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams.none(), + ): CompletableFuture = fetch(externalPlanId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -58,6 +97,14 @@ interface ExternalPlanIdServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: PlanExternalPlanIdFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(externalPlanId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(externalPlanId, PlanExternalPlanIdFetchParams.none(), requestOptions) + /** * A view of [ExternalPlanIdServiceAsync] that provides access to raw HTTP responses for each * method. @@ -69,9 +116,28 @@ interface ExternalPlanIdServiceAsync { * otherwise the same as [ExternalPlanIdServiceAsync.update]. */ @MustBeClosed + fun update(otherExternalPlanId: String): CompletableFuture> = + update(otherExternalPlanId, PlanExternalPlanIdUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: PlanExternalPlanIdUpdateParams - ): CompletableFuture> = update(params, RequestOptions.none()) + otherExternalPlanId: String, + params: PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update( + params.toBuilder().otherExternalPlanId(otherExternalPlanId).build(), + requestOptions, + ) + + /** @see [update] */ + @MustBeClosed + fun update( + otherExternalPlanId: String, + params: PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams.none(), + ): CompletableFuture> = + update(otherExternalPlanId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -80,13 +146,44 @@ interface ExternalPlanIdServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: PlanExternalPlanIdUpdateParams + ): CompletableFuture> = update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + otherExternalPlanId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(otherExternalPlanId, PlanExternalPlanIdUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /plans/external_plan_id/{external_plan_id}`, but is * otherwise the same as [ExternalPlanIdServiceAsync.fetch]. */ @MustBeClosed - fun fetch(params: PlanExternalPlanIdFetchParams): CompletableFuture> = - fetch(params, RequestOptions.none()) + fun fetch(externalPlanId: String): CompletableFuture> = + fetch(externalPlanId, PlanExternalPlanIdFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + externalPlanId: String, + params: PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().externalPlanId(externalPlanId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + externalPlanId: String, + params: PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams.none(), + ): CompletableFuture> = + fetch(externalPlanId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -94,5 +191,18 @@ interface ExternalPlanIdServiceAsync { params: PlanExternalPlanIdFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: PlanExternalPlanIdFetchParams): CompletableFuture> = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + externalPlanId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(externalPlanId, PlanExternalPlanIdFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt index 8d77ebf5..ca1c846f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.plans import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -19,6 +20,7 @@ import com.withorb.api.models.Plan import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class ExternalPlanIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdServiceAsync { @@ -55,6 +57,9 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdS params: PlanExternalPlanIdUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("otherExternalPlanId", params.otherExternalPlanId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -85,6 +90,9 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdS params: PlanExternalPlanIdFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalPlanId", params.externalPlanId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt index 702ab415..6b90d6a3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsync.kt @@ -21,8 +21,22 @@ interface ExternalPriceIdServiceAsync { * This endpoint allows you to update the `metadata` property on a price. If you pass null for * the metadata value, it will clear any existing metadata for that price. */ - fun update(params: PriceExternalPriceIdUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) + fun update(externalPriceId: String): CompletableFuture = + update(externalPriceId, PriceExternalPriceIdUpdateParams.none()) + + /** @see [update] */ + fun update( + externalPriceId: String, + params: PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().externalPriceId(externalPriceId).build(), requestOptions) + + /** @see [update] */ + fun update( + externalPriceId: String, + params: PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams.none(), + ): CompletableFuture = update(externalPriceId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -30,13 +44,35 @@ interface ExternalPriceIdServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [update] */ + fun update(params: PriceExternalPriceIdUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(externalPriceId: String, requestOptions: RequestOptions): CompletableFuture = + update(externalPriceId, PriceExternalPriceIdUpdateParams.none(), requestOptions) + /** * This endpoint returns a price given an external price id. See the * [price creation API](/api-reference/price/create-price) for more information about external * price aliases. */ - fun fetch(params: PriceExternalPriceIdFetchParams): CompletableFuture = - fetch(params, RequestOptions.none()) + fun fetch(externalPriceId: String): CompletableFuture = + fetch(externalPriceId, PriceExternalPriceIdFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + externalPriceId: String, + params: PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + fetch(params.toBuilder().externalPriceId(externalPriceId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + externalPriceId: String, + params: PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams.none(), + ): CompletableFuture = fetch(externalPriceId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -44,6 +80,14 @@ interface ExternalPriceIdServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** @see [fetch] */ + fun fetch(params: PriceExternalPriceIdFetchParams): CompletableFuture = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(externalPriceId: String, requestOptions: RequestOptions): CompletableFuture = + fetch(externalPriceId, PriceExternalPriceIdFetchParams.none(), requestOptions) + /** * A view of [ExternalPriceIdServiceAsync] that provides access to raw HTTP responses for each * method. @@ -55,9 +99,25 @@ interface ExternalPriceIdServiceAsync { * is otherwise the same as [ExternalPriceIdServiceAsync.update]. */ @MustBeClosed + fun update(externalPriceId: String): CompletableFuture> = + update(externalPriceId, PriceExternalPriceIdUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed fun update( - params: PriceExternalPriceIdUpdateParams - ): CompletableFuture> = update(params, RequestOptions.none()) + externalPriceId: String, + params: PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().externalPriceId(externalPriceId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + externalPriceId: String, + params: PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams.none(), + ): CompletableFuture> = + update(externalPriceId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -66,14 +126,44 @@ interface ExternalPriceIdServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** @see [update] */ + @MustBeClosed + fun update( + params: PriceExternalPriceIdUpdateParams + ): CompletableFuture> = update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + externalPriceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(externalPriceId, PriceExternalPriceIdUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /prices/external_price_id/{external_price_id}`, but * is otherwise the same as [ExternalPriceIdServiceAsync.fetch]. */ @MustBeClosed + fun fetch(externalPriceId: String): CompletableFuture> = + fetch(externalPriceId, PriceExternalPriceIdFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed fun fetch( - params: PriceExternalPriceIdFetchParams - ): CompletableFuture> = fetch(params, RequestOptions.none()) + externalPriceId: String, + params: PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + fetch(params.toBuilder().externalPriceId(externalPriceId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + externalPriceId: String, + params: PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams.none(), + ): CompletableFuture> = + fetch(externalPriceId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -81,5 +171,19 @@ interface ExternalPriceIdServiceAsync { params: PriceExternalPriceIdFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + params: PriceExternalPriceIdFetchParams + ): CompletableFuture> = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + externalPriceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + fetch(externalPriceId, PriceExternalPriceIdFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt index b8bf55ab..da2d7057 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.async.prices import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -19,6 +20,7 @@ import com.withorb.api.models.Price import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams import java.util.concurrent.CompletableFuture +import kotlin.jvm.optionals.getOrNull class ExternalPriceIdServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdServiceAsync { @@ -55,6 +57,9 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPriceId params: PriceExternalPriceIdUpdateParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalPriceId", params.externalPriceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -85,6 +90,9 @@ internal constructor(private val clientOptions: ClientOptions) : ExternalPriceId params: PriceExternalPriceIdFetchParams, requestOptions: RequestOptions, ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalPriceId", params.externalPriceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 e2b633a3..8d4a2b0f 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 @@ -24,7 +24,18 @@ interface AlertService { fun withRawResponse(): WithRawResponse /** This endpoint retrieves an alert by its ID. */ - fun retrieve(params: AlertRetrieveParams): Alert = retrieve(params, RequestOptions.none()) + fun retrieve(alertId: String): Alert = retrieve(alertId, AlertRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + alertId: String, + params: AlertRetrieveParams = AlertRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Alert = retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see [retrieve] */ + fun retrieve(alertId: String, params: AlertRetrieveParams = AlertRetrieveParams.none()): Alert = + retrieve(alertId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -32,7 +43,29 @@ interface AlertService { requestOptions: RequestOptions = RequestOptions.none(), ): Alert + /** @see [retrieve] */ + fun retrieve(params: AlertRetrieveParams): Alert = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve(alertId: String, requestOptions: RequestOptions): Alert = + retrieve(alertId, AlertRetrieveParams.none(), requestOptions) + /** This endpoint updates the thresholds of an alert. */ + fun update(alertConfigurationId: String, params: AlertUpdateParams): Alert = + update(alertConfigurationId, params, RequestOptions.none()) + + /** @see [update] */ + fun update( + alertConfigurationId: String, + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Alert = + update( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [update] */ fun update(params: AlertUpdateParams): Alert = update(params, RequestOptions.none()) /** @see [update] */ @@ -76,6 +109,17 @@ interface AlertService { * `credit_balance_dropped` alerts require a list of thresholds to be provided while * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. */ + fun createForCustomer(customerId: String, params: AlertCreateForCustomerParams): Alert = + createForCustomer(customerId, params, RequestOptions.none()) + + /** @see [createForCustomer] */ + fun createForCustomer( + customerId: String, + params: AlertCreateForCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Alert = createForCustomer(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [createForCustomer] */ fun createForCustomer(params: AlertCreateForCustomerParams): Alert = createForCustomer(params, RequestOptions.none()) @@ -93,6 +137,23 @@ interface AlertService { * `credit_balance_dropped` alerts require a list of thresholds to be provided while * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. */ + fun createForExternalCustomer( + externalCustomerId: String, + params: AlertCreateForExternalCustomerParams, + ): Alert = createForExternalCustomer(externalCustomerId, params, RequestOptions.none()) + + /** @see [createForExternalCustomer] */ + fun createForExternalCustomer( + externalCustomerId: String, + params: AlertCreateForExternalCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Alert = + createForExternalCustomer( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createForExternalCustomer] */ fun createForExternalCustomer(params: AlertCreateForExternalCustomerParams): Alert = createForExternalCustomer(params, RequestOptions.none()) @@ -114,6 +175,23 @@ interface AlertService { * per metric that is a part of the subscription. Alerts are triggered based on usage or cost * conditions met during the current billing cycle. */ + fun createForSubscription( + subscriptionId: String, + params: AlertCreateForSubscriptionParams, + ): Alert = createForSubscription(subscriptionId, params, RequestOptions.none()) + + /** @see [createForSubscription] */ + fun createForSubscription( + subscriptionId: String, + params: AlertCreateForSubscriptionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Alert = + createForSubscription( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [createForSubscription] */ fun createForSubscription(params: AlertCreateForSubscriptionParams): Alert = createForSubscription(params, RequestOptions.none()) @@ -128,7 +206,25 @@ interface AlertService { * subscription, you must include the `subscription_id`. The `subscription_id` is not required * for customer or subscription level alerts. */ - fun disable(params: AlertDisableParams): Alert = disable(params, RequestOptions.none()) + fun disable(alertConfigurationId: String): Alert = + disable(alertConfigurationId, AlertDisableParams.none()) + + /** @see [disable] */ + fun disable( + alertConfigurationId: String, + params: AlertDisableParams = AlertDisableParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Alert = + disable( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [disable] */ + fun disable( + alertConfigurationId: String, + params: AlertDisableParams = AlertDisableParams.none(), + ): Alert = disable(alertConfigurationId, params, RequestOptions.none()) /** @see [disable] */ fun disable( @@ -136,12 +232,37 @@ interface AlertService { requestOptions: RequestOptions = RequestOptions.none(), ): Alert + /** @see [disable] */ + fun disable(params: AlertDisableParams): Alert = disable(params, RequestOptions.none()) + + /** @see [disable] */ + fun disable(alertConfigurationId: String, requestOptions: RequestOptions): Alert = + disable(alertConfigurationId, AlertDisableParams.none(), requestOptions) + /** * This endpoint allows you to enable an alert. To enable a plan-level alert for a specific * subscription, you must include the `subscription_id`. The `subscription_id` is not required * for customer or subscription level alerts. */ - fun enable(params: AlertEnableParams): Alert = enable(params, RequestOptions.none()) + fun enable(alertConfigurationId: String): Alert = + enable(alertConfigurationId, AlertEnableParams.none()) + + /** @see [enable] */ + fun enable( + alertConfigurationId: String, + params: AlertEnableParams = AlertEnableParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Alert = + enable( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [enable] */ + fun enable( + alertConfigurationId: String, + params: AlertEnableParams = AlertEnableParams.none(), + ): Alert = enable(alertConfigurationId, params, RequestOptions.none()) /** @see [enable] */ fun enable( @@ -149,6 +270,13 @@ interface AlertService { requestOptions: RequestOptions = RequestOptions.none(), ): Alert + /** @see [enable] */ + fun enable(params: AlertEnableParams): Alert = enable(params, RequestOptions.none()) + + /** @see [enable] */ + fun enable(alertConfigurationId: String, requestOptions: RequestOptions): Alert = + enable(alertConfigurationId, AlertEnableParams.none(), requestOptions) + /** A view of [AlertService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -157,8 +285,24 @@ interface AlertService { * [AlertService.retrieve]. */ @MustBeClosed - fun retrieve(params: AlertRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve(alertId: String): HttpResponseFor = + retrieve(alertId, AlertRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + alertId: String, + params: AlertRetrieveParams = AlertRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().alertId(alertId).build(), requestOptions) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + alertId: String, + params: AlertRetrieveParams = AlertRetrieveParams.none(), + ): HttpResponseFor = retrieve(alertId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -167,11 +311,40 @@ interface AlertService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(params: AlertRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve(alertId: String, requestOptions: RequestOptions): HttpResponseFor = + retrieve(alertId, AlertRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `put /alerts/{alert_configuration_id}`, but is otherwise * the same as [AlertService.update]. */ @MustBeClosed + fun update( + alertConfigurationId: String, + params: AlertUpdateParams, + ): HttpResponseFor = update(alertConfigurationId, params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + alertConfigurationId: String, + params: AlertUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [update] */ + @MustBeClosed fun update(params: AlertUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) @@ -210,6 +383,22 @@ interface AlertService { * otherwise the same as [AlertService.createForCustomer]. */ @MustBeClosed + fun createForCustomer( + customerId: String, + params: AlertCreateForCustomerParams, + ): HttpResponseFor = createForCustomer(customerId, params, RequestOptions.none()) + + /** @see [createForCustomer] */ + @MustBeClosed + fun createForCustomer( + customerId: String, + params: AlertCreateForCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + createForCustomer(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [createForCustomer] */ + @MustBeClosed fun createForCustomer(params: AlertCreateForCustomerParams): HttpResponseFor = createForCustomer(params, RequestOptions.none()) @@ -226,6 +415,26 @@ interface AlertService { * [AlertService.createForExternalCustomer]. */ @MustBeClosed + fun createForExternalCustomer( + externalCustomerId: String, + params: AlertCreateForExternalCustomerParams, + ): HttpResponseFor = + createForExternalCustomer(externalCustomerId, params, RequestOptions.none()) + + /** @see [createForExternalCustomer] */ + @MustBeClosed + fun createForExternalCustomer( + externalCustomerId: String, + params: AlertCreateForExternalCustomerParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + createForExternalCustomer( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createForExternalCustomer] */ + @MustBeClosed fun createForExternalCustomer( params: AlertCreateForExternalCustomerParams ): HttpResponseFor = createForExternalCustomer(params, RequestOptions.none()) @@ -242,6 +451,26 @@ interface AlertService { * otherwise the same as [AlertService.createForSubscription]. */ @MustBeClosed + fun createForSubscription( + subscriptionId: String, + params: AlertCreateForSubscriptionParams, + ): HttpResponseFor = + createForSubscription(subscriptionId, params, RequestOptions.none()) + + /** @see [createForSubscription] */ + @MustBeClosed + fun createForSubscription( + subscriptionId: String, + params: AlertCreateForSubscriptionParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + createForSubscription( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [createForSubscription] */ + @MustBeClosed fun createForSubscription( params: AlertCreateForSubscriptionParams ): HttpResponseFor = createForSubscription(params, RequestOptions.none()) @@ -258,8 +487,27 @@ interface AlertService { * otherwise the same as [AlertService.disable]. */ @MustBeClosed - fun disable(params: AlertDisableParams): HttpResponseFor = - disable(params, RequestOptions.none()) + fun disable(alertConfigurationId: String): HttpResponseFor = + disable(alertConfigurationId, AlertDisableParams.none()) + + /** @see [disable] */ + @MustBeClosed + fun disable( + alertConfigurationId: String, + params: AlertDisableParams = AlertDisableParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + disable( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [disable] */ + @MustBeClosed + fun disable( + alertConfigurationId: String, + params: AlertDisableParams = AlertDisableParams.none(), + ): HttpResponseFor = disable(alertConfigurationId, params, RequestOptions.none()) /** @see [disable] */ @MustBeClosed @@ -268,13 +516,45 @@ interface AlertService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [disable] */ + @MustBeClosed + fun disable(params: AlertDisableParams): HttpResponseFor = + disable(params, RequestOptions.none()) + + /** @see [disable] */ + @MustBeClosed + fun disable( + alertConfigurationId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + disable(alertConfigurationId, AlertDisableParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/enable`, but is * otherwise the same as [AlertService.enable]. */ @MustBeClosed - fun enable(params: AlertEnableParams): HttpResponseFor = - enable(params, RequestOptions.none()) + fun enable(alertConfigurationId: String): HttpResponseFor = + enable(alertConfigurationId, AlertEnableParams.none()) + + /** @see [enable] */ + @MustBeClosed + fun enable( + alertConfigurationId: String, + params: AlertEnableParams = AlertEnableParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + enable( + params.toBuilder().alertConfigurationId(alertConfigurationId).build(), + requestOptions, + ) + + /** @see [enable] */ + @MustBeClosed + fun enable( + alertConfigurationId: String, + params: AlertEnableParams = AlertEnableParams.none(), + ): HttpResponseFor = enable(alertConfigurationId, params, RequestOptions.none()) /** @see [enable] */ @MustBeClosed @@ -282,5 +562,18 @@ interface AlertService { params: AlertEnableParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [enable] */ + @MustBeClosed + fun enable(params: AlertEnableParams): HttpResponseFor = + enable(params, RequestOptions.none()) + + /** @see [enable] */ + @MustBeClosed + fun enable( + alertConfigurationId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + enable(alertConfigurationId, AlertEnableParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt index 31e2fed9..c3c729de 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/AlertServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import com.withorb.api.models.AlertListPageResponse import com.withorb.api.models.AlertListParams import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams +import kotlin.jvm.optionals.getOrNull class AlertServiceImpl internal constructor(private val clientOptions: ClientOptions) : AlertService { @@ -89,6 +91,9 @@ class AlertServiceImpl internal constructor(private val clientOptions: ClientOpt params: AlertRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertId", params.alertId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -115,6 +120,9 @@ class AlertServiceImpl internal constructor(private val clientOptions: ClientOpt params: AlertUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertConfigurationId", params.alertConfigurationId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -176,6 +184,9 @@ class AlertServiceImpl internal constructor(private val clientOptions: ClientOpt params: AlertCreateForCustomerParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -203,6 +214,9 @@ class AlertServiceImpl internal constructor(private val clientOptions: ClientOpt params: AlertCreateForExternalCustomerParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -230,6 +244,9 @@ class AlertServiceImpl internal constructor(private val clientOptions: ClientOpt params: AlertCreateForSubscriptionParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -257,6 +274,9 @@ class AlertServiceImpl internal constructor(private val clientOptions: ClientOpt params: AlertDisableParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertConfigurationId", params.alertConfigurationId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -284,6 +304,9 @@ class AlertServiceImpl internal constructor(private val clientOptions: ClientOpt params: AlertEnableParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("alertConfigurationId", params.alertConfigurationId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt index 6a9a557a..e3c3e65e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponService.kt @@ -63,7 +63,20 @@ interface CouponService { * will be hidden from lists of active coupons. Additionally, once a coupon is archived, its * redemption code can be reused for a different coupon. */ - fun archive(params: CouponArchiveParams): Coupon = archive(params, RequestOptions.none()) + fun archive(couponId: String): Coupon = archive(couponId, CouponArchiveParams.none()) + + /** @see [archive] */ + fun archive( + couponId: String, + params: CouponArchiveParams = CouponArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Coupon = archive(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [archive] */ + fun archive( + couponId: String, + params: CouponArchiveParams = CouponArchiveParams.none(), + ): Coupon = archive(couponId, params, RequestOptions.none()) /** @see [archive] */ fun archive( @@ -71,11 +84,29 @@ interface CouponService { requestOptions: RequestOptions = RequestOptions.none(), ): Coupon + /** @see [archive] */ + fun archive(params: CouponArchiveParams): Coupon = archive(params, RequestOptions.none()) + + /** @see [archive] */ + fun archive(couponId: String, requestOptions: RequestOptions): Coupon = + archive(couponId, CouponArchiveParams.none(), requestOptions) + /** * This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption code, use * the [List coupons](list-coupons) endpoint with the redemption_code parameter. */ - fun fetch(params: CouponFetchParams): Coupon = fetch(params, RequestOptions.none()) + fun fetch(couponId: String): Coupon = fetch(couponId, CouponFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + couponId: String, + params: CouponFetchParams = CouponFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Coupon = fetch(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch(couponId: String, params: CouponFetchParams = CouponFetchParams.none()): Coupon = + fetch(couponId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -83,6 +114,13 @@ interface CouponService { requestOptions: RequestOptions = RequestOptions.none(), ): Coupon + /** @see [fetch] */ + fun fetch(params: CouponFetchParams): Coupon = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(couponId: String, requestOptions: RequestOptions): Coupon = + fetch(couponId, CouponFetchParams.none(), requestOptions) + /** A view of [CouponService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -132,8 +170,24 @@ interface CouponService { * same as [CouponService.archive]. */ @MustBeClosed - fun archive(params: CouponArchiveParams): HttpResponseFor = - archive(params, RequestOptions.none()) + fun archive(couponId: String): HttpResponseFor = + archive(couponId, CouponArchiveParams.none()) + + /** @see [archive] */ + @MustBeClosed + fun archive( + couponId: String, + params: CouponArchiveParams = CouponArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + archive(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [archive] */ + @MustBeClosed + fun archive( + couponId: String, + params: CouponArchiveParams = CouponArchiveParams.none(), + ): HttpResponseFor = archive(couponId, params, RequestOptions.none()) /** @see [archive] */ @MustBeClosed @@ -142,13 +196,39 @@ interface CouponService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [archive] */ + @MustBeClosed + fun archive(params: CouponArchiveParams): HttpResponseFor = + archive(params, RequestOptions.none()) + + /** @see [archive] */ + @MustBeClosed + fun archive(couponId: String, requestOptions: RequestOptions): HttpResponseFor = + archive(couponId, CouponArchiveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /coupons/{coupon_id}`, but is otherwise the same as * [CouponService.fetch]. */ @MustBeClosed - fun fetch(params: CouponFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(couponId: String): HttpResponseFor = + fetch(couponId, CouponFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + couponId: String, + params: CouponFetchParams = CouponFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + couponId: String, + params: CouponFetchParams = CouponFetchParams.none(), + ): HttpResponseFor = fetch(couponId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -156,5 +236,15 @@ interface CouponService { params: CouponFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: CouponFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch(couponId: String, requestOptions: RequestOptions): HttpResponseFor = + fetch(couponId, CouponFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt index 517aa4ba..5d27644d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CouponServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -24,6 +25,7 @@ import com.withorb.api.models.CouponListPageResponse import com.withorb.api.models.CouponListParams import com.withorb.api.services.blocking.coupons.SubscriptionService import com.withorb.api.services.blocking.coupons.SubscriptionServiceImpl +import kotlin.jvm.optionals.getOrNull class CouponServiceImpl internal constructor(private val clientOptions: ClientOptions) : CouponService { @@ -135,6 +137,9 @@ class CouponServiceImpl internal constructor(private val clientOptions: ClientOp params: CouponArchiveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("couponId", params.couponId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -162,6 +167,9 @@ class CouponServiceImpl internal constructor(private val clientOptions: ClientOp params: CouponFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("couponId", params.couponId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt index a2e0cba4..972aaf76 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteService.kt @@ -52,7 +52,20 @@ interface CreditNoteService { * This endpoint is used to fetch a single [`Credit Note`](/invoicing/credit-notes) given an * identifier. */ - fun fetch(params: CreditNoteFetchParams): CreditNote = fetch(params, RequestOptions.none()) + fun fetch(creditNoteId: String): CreditNote = fetch(creditNoteId, CreditNoteFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + creditNoteId: String, + params: CreditNoteFetchParams = CreditNoteFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditNote = fetch(params.toBuilder().creditNoteId(creditNoteId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + creditNoteId: String, + params: CreditNoteFetchParams = CreditNoteFetchParams.none(), + ): CreditNote = fetch(creditNoteId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -60,6 +73,13 @@ interface CreditNoteService { requestOptions: RequestOptions = RequestOptions.none(), ): CreditNote + /** @see [fetch] */ + fun fetch(params: CreditNoteFetchParams): CreditNote = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(creditNoteId: String, requestOptions: RequestOptions): CreditNote = + fetch(creditNoteId, CreditNoteFetchParams.none(), requestOptions) + /** A view of [CreditNoteService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -108,8 +128,24 @@ interface CreditNoteService { * the same as [CreditNoteService.fetch]. */ @MustBeClosed - fun fetch(params: CreditNoteFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(creditNoteId: String): HttpResponseFor = + fetch(creditNoteId, CreditNoteFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + creditNoteId: String, + params: CreditNoteFetchParams = CreditNoteFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().creditNoteId(creditNoteId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + creditNoteId: String, + params: CreditNoteFetchParams = CreditNoteFetchParams.none(), + ): HttpResponseFor = fetch(creditNoteId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -117,5 +153,18 @@ interface CreditNoteService { params: CreditNoteFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: CreditNoteFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + creditNoteId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + fetch(creditNoteId, CreditNoteFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt index a036d08b..883d149a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CreditNoteServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -21,6 +22,7 @@ import com.withorb.api.models.CreditNoteFetchParams import com.withorb.api.models.CreditNoteListPage import com.withorb.api.models.CreditNoteListPageResponse import com.withorb.api.models.CreditNoteListParams +import kotlin.jvm.optionals.getOrNull class CreditNoteServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditNoteService { @@ -122,6 +124,9 @@ class CreditNoteServiceImpl internal constructor(private val clientOptions: Clie params: CreditNoteFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("creditNoteId", params.creditNoteId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 2d62be98..ac6eecbc 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 @@ -61,7 +61,20 @@ interface CustomerService { * `billing_address`, and `additional_emails` of an existing customer. Other fields on a * customer are currently immutable. */ - fun update(params: CustomerUpdateParams): Customer = update(params, RequestOptions.none()) + fun update(customerId: String): Customer = update(customerId, CustomerUpdateParams.none()) + + /** @see [update] */ + fun update( + customerId: String, + params: CustomerUpdateParams = CustomerUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Customer = update(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [update] */ + fun update( + customerId: String, + params: CustomerUpdateParams = CustomerUpdateParams.none(), + ): Customer = update(customerId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -69,6 +82,13 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): Customer + /** @see [update] */ + fun update(params: CustomerUpdateParams): Customer = update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(customerId: String, requestOptions: RequestOptions): Customer = + update(customerId, CustomerUpdateParams.none(), requestOptions) + /** * This endpoint returns a list of all customers for an account. The list of customers is * ordered starting from the most recently created customer. This endpoint follows Orb's @@ -107,11 +127,29 @@ interface CustomerService { * * On successful processing, this returns an empty dictionary (`{}`) in the API. */ - fun delete(params: CustomerDeleteParams) = delete(params, RequestOptions.none()) + fun delete(customerId: String) = delete(customerId, CustomerDeleteParams.none()) + + /** @see [delete] */ + fun delete( + customerId: String, + params: CustomerDeleteParams = CustomerDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [delete] */ + fun delete(customerId: String, params: CustomerDeleteParams = CustomerDeleteParams.none()) = + delete(customerId, params, RequestOptions.none()) /** @see [delete] */ fun delete(params: CustomerDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + /** @see [delete] */ + fun delete(params: CustomerDeleteParams) = delete(params, RequestOptions.none()) + + /** @see [delete] */ + fun delete(customerId: String, requestOptions: RequestOptions) = + delete(customerId, CustomerDeleteParams.none(), requestOptions) + /** * This endpoint is used to fetch customer details given an identifier. If the `Customer` is in * the process of being deleted, only the properties `id` and `deleted: true` will be returned. @@ -119,7 +157,20 @@ interface CustomerService { * See the [Customer resource](/core-concepts#customer) for a full discussion of the Customer * model. */ - fun fetch(params: CustomerFetchParams): Customer = fetch(params, RequestOptions.none()) + fun fetch(customerId: String): Customer = fetch(customerId, CustomerFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + customerId: String, + params: CustomerFetchParams = CustomerFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Customer = fetch(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + customerId: String, + params: CustomerFetchParams = CustomerFetchParams.none(), + ): Customer = fetch(customerId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -127,6 +178,13 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): Customer + /** @see [fetch] */ + fun fetch(params: CustomerFetchParams): Customer = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(customerId: String, requestOptions: RequestOptions): Customer = + fetch(customerId, CustomerFetchParams.none(), requestOptions) + /** * This endpoint is used to fetch customer details given an `external_customer_id` (see * [Customer ID Aliases](/events-and-metrics/customer-aliases)). @@ -134,8 +192,25 @@ interface CustomerService { * Note that the resource and semantics of this endpoint exactly mirror * [Get Customer](fetch-customer). */ - fun fetchByExternalId(params: CustomerFetchByExternalIdParams): Customer = - fetchByExternalId(params, RequestOptions.none()) + fun fetchByExternalId(externalCustomerId: String): Customer = + fetchByExternalId(externalCustomerId, CustomerFetchByExternalIdParams.none()) + + /** @see [fetchByExternalId] */ + fun fetchByExternalId( + externalCustomerId: String, + params: CustomerFetchByExternalIdParams = CustomerFetchByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Customer = + fetchByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [fetchByExternalId] */ + fun fetchByExternalId( + externalCustomerId: String, + params: CustomerFetchByExternalIdParams = CustomerFetchByExternalIdParams.none(), + ): Customer = fetchByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [fetchByExternalId] */ fun fetchByExternalId( @@ -143,6 +218,18 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): Customer + /** @see [fetchByExternalId] */ + fun fetchByExternalId(params: CustomerFetchByExternalIdParams): Customer = + fetchByExternalId(params, RequestOptions.none()) + + /** @see [fetchByExternalId] */ + fun fetchByExternalId(externalCustomerId: String, requestOptions: RequestOptions): Customer = + fetchByExternalId( + externalCustomerId, + CustomerFetchByExternalIdParams.none(), + requestOptions, + ) + /** * Sync Orb's payment methods for the customer with their gateway. * @@ -151,8 +238,30 @@ interface CustomerService { * * **Note**: This functionality is currently only available for Stripe. */ - fun syncPaymentMethodsFromGateway(params: CustomerSyncPaymentMethodsFromGatewayParams) = - syncPaymentMethodsFromGateway(params, RequestOptions.none()) + fun syncPaymentMethodsFromGateway(customerId: String) = + syncPaymentMethodsFromGateway( + customerId, + CustomerSyncPaymentMethodsFromGatewayParams.none(), + ) + + /** @see [syncPaymentMethodsFromGateway] */ + fun syncPaymentMethodsFromGateway( + customerId: String, + params: CustomerSyncPaymentMethodsFromGatewayParams = + CustomerSyncPaymentMethodsFromGatewayParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = + syncPaymentMethodsFromGateway( + params.toBuilder().customerId(customerId).build(), + requestOptions, + ) + + /** @see [syncPaymentMethodsFromGateway] */ + fun syncPaymentMethodsFromGateway( + customerId: String, + params: CustomerSyncPaymentMethodsFromGatewayParams = + CustomerSyncPaymentMethodsFromGatewayParams.none(), + ) = syncPaymentMethodsFromGateway(customerId, params, RequestOptions.none()) /** @see [syncPaymentMethodsFromGateway] */ fun syncPaymentMethodsFromGateway( @@ -160,6 +269,18 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ) + /** @see [syncPaymentMethodsFromGateway] */ + fun syncPaymentMethodsFromGateway(params: CustomerSyncPaymentMethodsFromGatewayParams) = + syncPaymentMethodsFromGateway(params, RequestOptions.none()) + + /** @see [syncPaymentMethodsFromGateway] */ + fun syncPaymentMethodsFromGateway(customerId: String, requestOptions: RequestOptions) = + syncPaymentMethodsFromGateway( + customerId, + CustomerSyncPaymentMethodsFromGatewayParams.none(), + requestOptions, + ) + /** * Sync Orb's payment methods for the customer with their gateway. * @@ -168,9 +289,35 @@ interface CustomerService { * * **Note**: This functionality is currently only available for Stripe. */ + fun syncPaymentMethodsFromGatewayByExternalCustomerId(externalCustomerId: String) = + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + ) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ fun syncPaymentMethodsFromGatewayByExternalCustomerId( - params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams - ) = syncPaymentMethodsFromGatewayByExternalCustomerId(params, RequestOptions.none()) + externalCustomerId: String, + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = + syncPaymentMethodsFromGatewayByExternalCustomerId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + ) = + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + params, + RequestOptions.none(), + ) /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ fun syncPaymentMethodsFromGatewayByExternalCustomerId( @@ -178,13 +325,42 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ) + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams + ) = syncPaymentMethodsFromGatewayByExternalCustomerId(params, RequestOptions.none()) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + requestOptions: RequestOptions, + ) = + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + requestOptions, + ) + /** * This endpoint is used to update customer details given an `external_customer_id` (see * [Customer ID Aliases](/events-and-metrics/customer-aliases)). Note that the resource and * semantics of this endpoint exactly mirror [Update Customer](update-customer). */ - fun updateByExternalId(params: CustomerUpdateByExternalIdParams): Customer = - updateByExternalId(params, RequestOptions.none()) + fun updateByExternalId(id: String): Customer = + updateByExternalId(id, CustomerUpdateByExternalIdParams.none()) + + /** @see [updateByExternalId] */ + fun updateByExternalId( + id: String, + params: CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Customer = updateByExternalId(params.toBuilder().id(id).build(), requestOptions) + + /** @see [updateByExternalId] */ + fun updateByExternalId( + id: String, + params: CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams.none(), + ): Customer = updateByExternalId(id, params, RequestOptions.none()) /** @see [updateByExternalId] */ fun updateByExternalId( @@ -192,6 +368,14 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): Customer + /** @see [updateByExternalId] */ + fun updateByExternalId(params: CustomerUpdateByExternalIdParams): Customer = + updateByExternalId(params, RequestOptions.none()) + + /** @see [updateByExternalId] */ + fun updateByExternalId(id: String, requestOptions: RequestOptions): Customer = + updateByExternalId(id, CustomerUpdateByExternalIdParams.none(), requestOptions) + /** A view of [CustomerService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -221,8 +405,24 @@ interface CustomerService { * as [CustomerService.update]. */ @MustBeClosed - fun update(params: CustomerUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(customerId: String): HttpResponseFor = + update(customerId, CustomerUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + customerId: String, + params: CustomerUpdateParams = CustomerUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + customerId: String, + params: CustomerUpdateParams = CustomerUpdateParams.none(), + ): HttpResponseFor = update(customerId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -231,6 +431,16 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: CustomerUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update(customerId: String, requestOptions: RequestOptions): HttpResponseFor = + update(customerId, CustomerUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /customers`, but is otherwise the same as * [CustomerService.list]. @@ -261,8 +471,23 @@ interface CustomerService { * same as [CustomerService.delete]. */ @MustBeClosed - fun delete(params: CustomerDeleteParams): HttpResponse = - delete(params, RequestOptions.none()) + fun delete(customerId: String): HttpResponse = + delete(customerId, CustomerDeleteParams.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + customerId: String, + params: CustomerDeleteParams = CustomerDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed + fun delete( + customerId: String, + params: CustomerDeleteParams = CustomerDeleteParams.none(), + ): HttpResponse = delete(customerId, params, RequestOptions.none()) /** @see [delete] */ @MustBeClosed @@ -271,13 +496,39 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse + /** @see [delete] */ + @MustBeClosed + fun delete(params: CustomerDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete(customerId: String, requestOptions: RequestOptions): HttpResponse = + delete(customerId, CustomerDeleteParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /customers/{customer_id}`, but is otherwise the same * as [CustomerService.fetch]. */ @MustBeClosed - fun fetch(params: CustomerFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(customerId: String): HttpResponseFor = + fetch(customerId, CustomerFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + customerId: String, + params: CustomerFetchParams = CustomerFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + customerId: String, + params: CustomerFetchParams = CustomerFetchParams.none(), + ): HttpResponseFor = fetch(customerId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -286,14 +537,44 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: CustomerFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch(customerId: String, requestOptions: RequestOptions): HttpResponseFor = + fetch(customerId, CustomerFetchParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get * /customers/external_customer_id/{external_customer_id}`, but is otherwise the same as * [CustomerService.fetchByExternalId]. */ @MustBeClosed - fun fetchByExternalId(params: CustomerFetchByExternalIdParams): HttpResponseFor = - fetchByExternalId(params, RequestOptions.none()) + fun fetchByExternalId(externalCustomerId: String): HttpResponseFor = + fetchByExternalId(externalCustomerId, CustomerFetchByExternalIdParams.none()) + + /** @see [fetchByExternalId] */ + @MustBeClosed + fun fetchByExternalId( + externalCustomerId: String, + params: CustomerFetchByExternalIdParams = CustomerFetchByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetchByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [fetchByExternalId] */ + @MustBeClosed + fun fetchByExternalId( + externalCustomerId: String, + params: CustomerFetchByExternalIdParams = CustomerFetchByExternalIdParams.none(), + ): HttpResponseFor = + fetchByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [fetchByExternalId] */ @MustBeClosed @@ -302,15 +583,55 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [fetchByExternalId] */ + @MustBeClosed + fun fetchByExternalId(params: CustomerFetchByExternalIdParams): HttpResponseFor = + fetchByExternalId(params, RequestOptions.none()) + + /** @see [fetchByExternalId] */ + @MustBeClosed + fun fetchByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + fetchByExternalId( + externalCustomerId, + CustomerFetchByExternalIdParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `post * /customers/{customer_id}/sync_payment_methods_from_gateway`, but is otherwise the same as * [CustomerService.syncPaymentMethodsFromGateway]. */ @MustBeClosed + fun syncPaymentMethodsFromGateway(customerId: String): HttpResponse = + syncPaymentMethodsFromGateway( + customerId, + CustomerSyncPaymentMethodsFromGatewayParams.none(), + ) + + /** @see [syncPaymentMethodsFromGateway] */ + @MustBeClosed fun syncPaymentMethodsFromGateway( - params: CustomerSyncPaymentMethodsFromGatewayParams - ): HttpResponse = syncPaymentMethodsFromGateway(params, RequestOptions.none()) + customerId: String, + params: CustomerSyncPaymentMethodsFromGatewayParams = + CustomerSyncPaymentMethodsFromGatewayParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = + syncPaymentMethodsFromGateway( + params.toBuilder().customerId(customerId).build(), + requestOptions, + ) + + /** @see [syncPaymentMethodsFromGateway] */ + @MustBeClosed + fun syncPaymentMethodsFromGateway( + customerId: String, + params: CustomerSyncPaymentMethodsFromGatewayParams = + CustomerSyncPaymentMethodsFromGatewayParams.none(), + ): HttpResponse = syncPaymentMethodsFromGateway(customerId, params, RequestOptions.none()) /** @see [syncPaymentMethodsFromGateway] */ @MustBeClosed @@ -319,6 +640,24 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse + /** @see [syncPaymentMethodsFromGateway] */ + @MustBeClosed + fun syncPaymentMethodsFromGateway( + params: CustomerSyncPaymentMethodsFromGatewayParams + ): HttpResponse = syncPaymentMethodsFromGateway(params, RequestOptions.none()) + + /** @see [syncPaymentMethodsFromGateway] */ + @MustBeClosed + fun syncPaymentMethodsFromGateway( + customerId: String, + requestOptions: RequestOptions, + ): HttpResponse = + syncPaymentMethodsFromGateway( + customerId, + CustomerSyncPaymentMethodsFromGatewayParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `post * /customers/external_customer_id/{external_customer_id}/sync_payment_methods_from_gateway`, @@ -327,9 +666,38 @@ interface CustomerService { */ @MustBeClosed fun syncPaymentMethodsFromGatewayByExternalCustomerId( - params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams + externalCustomerId: String ): HttpResponse = - syncPaymentMethodsFromGatewayByExternalCustomerId(params, RequestOptions.none()) + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + ) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = + syncPaymentMethodsFromGatewayByExternalCustomerId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams = + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + ): HttpResponse = + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + params, + RequestOptions.none(), + ) /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ @MustBeClosed @@ -338,15 +706,49 @@ interface CustomerService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams + ): HttpResponse = + syncPaymentMethodsFromGatewayByExternalCustomerId(params, RequestOptions.none()) + + /** @see [syncPaymentMethodsFromGatewayByExternalCustomerId] */ + @MustBeClosed + fun syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): HttpResponse = + syncPaymentMethodsFromGatewayByExternalCustomerId( + externalCustomerId, + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `put * /customers/external_customer_id/{external_customer_id}`, but is otherwise the same as * [CustomerService.updateByExternalId]. */ @MustBeClosed + fun updateByExternalId(id: String): HttpResponseFor = + updateByExternalId(id, CustomerUpdateByExternalIdParams.none()) + + /** @see [updateByExternalId] */ + @MustBeClosed fun updateByExternalId( - params: CustomerUpdateByExternalIdParams - ): HttpResponseFor = updateByExternalId(params, RequestOptions.none()) + id: String, + params: CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + updateByExternalId(params.toBuilder().id(id).build(), requestOptions) + + /** @see [updateByExternalId] */ + @MustBeClosed + fun updateByExternalId( + id: String, + params: CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams.none(), + ): HttpResponseFor = updateByExternalId(id, params, RequestOptions.none()) /** @see [updateByExternalId] */ @MustBeClosed @@ -354,5 +756,19 @@ interface CustomerService { params: CustomerUpdateByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [updateByExternalId] */ + @MustBeClosed + fun updateByExternalId( + params: CustomerUpdateByExternalIdParams + ): HttpResponseFor = updateByExternalId(params, RequestOptions.none()) + + /** @see [updateByExternalId] */ + @MustBeClosed + fun updateByExternalId( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + updateByExternalId(id, CustomerUpdateByExternalIdParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt index da329b17..06e16345 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/CustomerServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.emptyHandler import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler @@ -35,6 +36,7 @@ import com.withorb.api.services.blocking.customers.CostService import com.withorb.api.services.blocking.customers.CostServiceImpl import com.withorb.api.services.blocking.customers.CreditService import com.withorb.api.services.blocking.customers.CreditServiceImpl +import kotlin.jvm.optionals.getOrNull class CustomerServiceImpl internal constructor(private val clientOptions: ClientOptions) : CustomerService { @@ -172,6 +174,9 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client params: CustomerUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -232,6 +237,9 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client params: CustomerDeleteParams, requestOptions: RequestOptions, ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -251,6 +259,9 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client params: CustomerFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -277,6 +288,9 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client params: CustomerFetchByExternalIdParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -303,6 +317,9 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client params: CustomerSyncPaymentMethodsFromGatewayParams, requestOptions: RequestOptions, ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -328,6 +345,9 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client params: CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams, requestOptions: RequestOptions, ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -354,6 +374,9 @@ class CustomerServiceImpl internal constructor(private val clientOptions: Client params: CustomerUpdateByExternalIdParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) 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 862f9925..8df6a108 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 @@ -40,8 +40,25 @@ interface DimensionalPriceGroupService { ): DimensionalPriceGroup /** Fetch dimensional price group */ - fun retrieve(params: DimensionalPriceGroupRetrieveParams): DimensionalPriceGroup = - retrieve(params, RequestOptions.none()) + fun retrieve(dimensionalPriceGroupId: String): DimensionalPriceGroup = + retrieve(dimensionalPriceGroupId, DimensionalPriceGroupRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + dimensionalPriceGroupId: String, + params: DimensionalPriceGroupRetrieveParams = DimensionalPriceGroupRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DimensionalPriceGroup = + retrieve( + params.toBuilder().dimensionalPriceGroupId(dimensionalPriceGroupId).build(), + requestOptions, + ) + + /** @see [retrieve] */ + fun retrieve( + dimensionalPriceGroupId: String, + params: DimensionalPriceGroupRetrieveParams = DimensionalPriceGroupRetrieveParams.none(), + ): DimensionalPriceGroup = retrieve(dimensionalPriceGroupId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -49,6 +66,21 @@ interface DimensionalPriceGroupService { requestOptions: RequestOptions = RequestOptions.none(), ): DimensionalPriceGroup + /** @see [retrieve] */ + fun retrieve(params: DimensionalPriceGroupRetrieveParams): DimensionalPriceGroup = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + dimensionalPriceGroupId: String, + requestOptions: RequestOptions, + ): DimensionalPriceGroup = + retrieve( + dimensionalPriceGroupId, + DimensionalPriceGroupRetrieveParams.none(), + requestOptions, + ) + /** List dimensional price groups */ fun list(): DimensionalPriceGroupListPage = list(DimensionalPriceGroupListParams.none()) @@ -98,9 +130,29 @@ interface DimensionalPriceGroupService { * [DimensionalPriceGroupService.retrieve]. */ @MustBeClosed + fun retrieve(dimensionalPriceGroupId: String): HttpResponseFor = + retrieve(dimensionalPriceGroupId, DimensionalPriceGroupRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed fun retrieve( - params: DimensionalPriceGroupRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) + dimensionalPriceGroupId: String, + params: DimensionalPriceGroupRetrieveParams = + DimensionalPriceGroupRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve( + params.toBuilder().dimensionalPriceGroupId(dimensionalPriceGroupId).build(), + requestOptions, + ) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + dimensionalPriceGroupId: String, + params: DimensionalPriceGroupRetrieveParams = DimensionalPriceGroupRetrieveParams.none(), + ): HttpResponseFor = + retrieve(dimensionalPriceGroupId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -109,6 +161,24 @@ interface DimensionalPriceGroupService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: DimensionalPriceGroupRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + dimensionalPriceGroupId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve( + dimensionalPriceGroupId, + DimensionalPriceGroupRetrieveParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `get /dimensional_price_groups`, but is otherwise the * same as [DimensionalPriceGroupService.list]. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt index 5aef9624..7f600f1d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -23,6 +24,7 @@ import com.withorb.api.models.DimensionalPriceGroupRetrieveParams import com.withorb.api.models.DimensionalPriceGroups import com.withorb.api.services.blocking.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdService import com.withorb.api.services.blocking.dimensionalPriceGroups.ExternalDimensionalPriceGroupIdServiceImpl +import kotlin.jvm.optionals.getOrNull class DimensionalPriceGroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : DimensionalPriceGroupService { @@ -110,6 +112,9 @@ internal constructor(private val clientOptions: ClientOptions) : DimensionalPric params: DimensionalPriceGroupRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("dimensionalPriceGroupId", params.dimensionalPriceGroupId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 fbf459ff..432a8d3a 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 @@ -68,6 +68,17 @@ interface EventService { * period. For higher volume updates, consider using the [event backfill](create-backfill) * endpoint. */ + fun update(eventId: String, params: EventUpdateParams): EventUpdateResponse = + update(eventId, params, RequestOptions.none()) + + /** @see [update] */ + fun update( + eventId: String, + params: EventUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): EventUpdateResponse = update(params.toBuilder().eventId(eventId).build(), requestOptions) + + /** @see [update] */ fun update(params: EventUpdateParams): EventUpdateResponse = update(params, RequestOptions.none()) @@ -113,8 +124,22 @@ interface EventService { * period. For higher volume updates, consider using the [event backfill](create-backfill) * endpoint. */ - fun deprecate(params: EventDeprecateParams): EventDeprecateResponse = - deprecate(params, RequestOptions.none()) + fun deprecate(eventId: String): EventDeprecateResponse = + deprecate(eventId, EventDeprecateParams.none()) + + /** @see [deprecate] */ + fun deprecate( + eventId: String, + params: EventDeprecateParams = EventDeprecateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EventDeprecateResponse = + deprecate(params.toBuilder().eventId(eventId).build(), requestOptions) + + /** @see [deprecate] */ + fun deprecate( + eventId: String, + params: EventDeprecateParams = EventDeprecateParams.none(), + ): EventDeprecateResponse = deprecate(eventId, params, RequestOptions.none()) /** @see [deprecate] */ fun deprecate( @@ -122,6 +147,14 @@ interface EventService { requestOptions: RequestOptions = RequestOptions.none(), ): EventDeprecateResponse + /** @see [deprecate] */ + fun deprecate(params: EventDeprecateParams): EventDeprecateResponse = + deprecate(params, RequestOptions.none()) + + /** @see [deprecate] */ + fun deprecate(eventId: String, requestOptions: RequestOptions): EventDeprecateResponse = + deprecate(eventId, EventDeprecateParams.none(), requestOptions) + /** * Orb's event ingestion model and API is designed around two core principles: * 1. **Data fidelity**: The accuracy of your billing model depends on a robust foundation of @@ -359,6 +392,22 @@ interface EventService { * [EventService.update]. */ @MustBeClosed + fun update( + eventId: String, + params: EventUpdateParams, + ): HttpResponseFor = update(eventId, params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + eventId: String, + params: EventUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().eventId(eventId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed fun update(params: EventUpdateParams): HttpResponseFor = update(params, RequestOptions.none()) @@ -374,8 +423,25 @@ interface EventService { * same as [EventService.deprecate]. */ @MustBeClosed - fun deprecate(params: EventDeprecateParams): HttpResponseFor = - deprecate(params, RequestOptions.none()) + fun deprecate(eventId: String): HttpResponseFor = + deprecate(eventId, EventDeprecateParams.none()) + + /** @see [deprecate] */ + @MustBeClosed + fun deprecate( + eventId: String, + params: EventDeprecateParams = EventDeprecateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + deprecate(params.toBuilder().eventId(eventId).build(), requestOptions) + + /** @see [deprecate] */ + @MustBeClosed + fun deprecate( + eventId: String, + params: EventDeprecateParams = EventDeprecateParams.none(), + ): HttpResponseFor = + deprecate(eventId, params, RequestOptions.none()) /** @see [deprecate] */ @MustBeClosed @@ -384,6 +450,19 @@ interface EventService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [deprecate] */ + @MustBeClosed + fun deprecate(params: EventDeprecateParams): HttpResponseFor = + deprecate(params, RequestOptions.none()) + + /** @see [deprecate] */ + @MustBeClosed + fun deprecate( + eventId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + deprecate(eventId, EventDeprecateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /ingest`, but is otherwise the same as * [EventService.ingest]. diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt index 9a48a553..7c3bb7c3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/EventServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -27,6 +28,7 @@ import com.withorb.api.services.blocking.events.BackfillService import com.withorb.api.services.blocking.events.BackfillServiceImpl import com.withorb.api.services.blocking.events.VolumeService import com.withorb.api.services.blocking.events.VolumeServiceImpl +import kotlin.jvm.optionals.getOrNull class EventServiceImpl internal constructor(private val clientOptions: ClientOptions) : EventService { @@ -98,6 +100,9 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt params: EventUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("eventId", params.eventId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -126,6 +131,9 @@ class EventServiceImpl internal constructor(private val clientOptions: ClientOpt params: EventDeprecateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("eventId", params.eventId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) 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 8aa45bfb..ff6d4926 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 @@ -40,7 +40,20 @@ interface InvoiceService { * * `metadata` can be modified regardless of invoice state. */ - fun update(params: InvoiceUpdateParams): Invoice = update(params, RequestOptions.none()) + fun update(invoiceId: String): Invoice = update(invoiceId, InvoiceUpdateParams.none()) + + /** @see [update] */ + fun update( + invoiceId: String, + params: InvoiceUpdateParams = InvoiceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Invoice = update(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [update] */ + fun update( + invoiceId: String, + params: InvoiceUpdateParams = InvoiceUpdateParams.none(), + ): Invoice = update(invoiceId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -48,6 +61,13 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): Invoice + /** @see [update] */ + fun update(params: InvoiceUpdateParams): Invoice = update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(invoiceId: String, requestOptions: RequestOptions): Invoice = + update(invoiceId, InvoiceUpdateParams.none(), requestOptions) + /** * This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s for an account in a * list format. @@ -81,7 +101,18 @@ interface InvoiceService { /** * This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an identifier. */ - fun fetch(params: InvoiceFetchParams): Invoice = fetch(params, RequestOptions.none()) + fun fetch(invoiceId: String): Invoice = fetch(invoiceId, InvoiceFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + invoiceId: String, + params: InvoiceFetchParams = InvoiceFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Invoice = fetch(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch(invoiceId: String, params: InvoiceFetchParams = InvoiceFetchParams.none()): Invoice = + fetch(invoiceId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -89,6 +120,13 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): Invoice + /** @see [fetch] */ + fun fetch(params: InvoiceFetchParams): Invoice = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(invoiceId: String, requestOptions: RequestOptions): Invoice = + fetch(invoiceId, InvoiceFetchParams.none(), requestOptions) + /** * This endpoint can be used to fetch the upcoming [invoice](/core-concepts#invoice) for the * current billing period given a subscription. @@ -109,7 +147,18 @@ interface InvoiceService { * could be customer-visible (e.g. sending emails, auto-collecting payment, syncing the invoice * to external providers, etc). */ - fun issue(params: InvoiceIssueParams): Invoice = issue(params, RequestOptions.none()) + fun issue(invoiceId: String): Invoice = issue(invoiceId, InvoiceIssueParams.none()) + + /** @see [issue] */ + fun issue( + invoiceId: String, + params: InvoiceIssueParams = InvoiceIssueParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Invoice = issue(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [issue] */ + fun issue(invoiceId: String, params: InvoiceIssueParams = InvoiceIssueParams.none()): Invoice = + issue(invoiceId, params, RequestOptions.none()) /** @see [issue] */ fun issue( @@ -117,10 +166,28 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): Invoice + /** @see [issue] */ + fun issue(params: InvoiceIssueParams): Invoice = issue(params, RequestOptions.none()) + + /** @see [issue] */ + fun issue(invoiceId: String, requestOptions: RequestOptions): Invoice = + 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. */ + fun markPaid(invoiceId: String, params: InvoiceMarkPaidParams): Invoice = + markPaid(invoiceId, params, RequestOptions.none()) + + /** @see [markPaid] */ + fun markPaid( + invoiceId: String, + params: InvoiceMarkPaidParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Invoice = markPaid(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [markPaid] */ fun markPaid(params: InvoiceMarkPaidParams): Invoice = markPaid(params, RequestOptions.none()) /** @see [markPaid] */ @@ -133,7 +200,18 @@ interface InvoiceService { * This endpoint collects payment for an invoice using the customer's default payment method. * This action can only be taken on invoices with status "issued". */ - fun pay(params: InvoicePayParams): Invoice = pay(params, RequestOptions.none()) + fun pay(invoiceId: String): Invoice = pay(invoiceId, InvoicePayParams.none()) + + /** @see [pay] */ + fun pay( + invoiceId: String, + params: InvoicePayParams = InvoicePayParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Invoice = pay(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [pay] */ + fun pay(invoiceId: String, params: InvoicePayParams = InvoicePayParams.none()): Invoice = + pay(invoiceId, params, RequestOptions.none()) /** @see [pay] */ fun pay( @@ -141,6 +219,13 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): Invoice + /** @see [pay] */ + fun pay(params: InvoicePayParams): Invoice = pay(params, RequestOptions.none()) + + /** @see [pay] */ + fun pay(invoiceId: String, requestOptions: RequestOptions): Invoice = + 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. @@ -153,8 +238,21 @@ interface InvoiceService { * credit block will be voided. If the invoice was created due to a top-up, the top-up will be * disabled. */ - fun voidInvoice(params: InvoiceVoidInvoiceParams): Invoice = - voidInvoice(params, RequestOptions.none()) + fun voidInvoice(invoiceId: String): Invoice = + voidInvoice(invoiceId, InvoiceVoidInvoiceParams.none()) + + /** @see [voidInvoice] */ + fun voidInvoice( + invoiceId: String, + params: InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Invoice = voidInvoice(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [voidInvoice] */ + fun voidInvoice( + invoiceId: String, + params: InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams.none(), + ): Invoice = voidInvoice(invoiceId, params, RequestOptions.none()) /** @see [voidInvoice] */ fun voidInvoice( @@ -162,6 +260,14 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): Invoice + /** @see [voidInvoice] */ + fun voidInvoice(params: InvoiceVoidInvoiceParams): Invoice = + voidInvoice(params, RequestOptions.none()) + + /** @see [voidInvoice] */ + fun voidInvoice(invoiceId: String, requestOptions: RequestOptions): Invoice = + voidInvoice(invoiceId, InvoiceVoidInvoiceParams.none(), requestOptions) + /** A view of [InvoiceService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -185,8 +291,24 @@ interface InvoiceService { * as [InvoiceService.update]. */ @MustBeClosed - fun update(params: InvoiceUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(invoiceId: String): HttpResponseFor = + update(invoiceId, InvoiceUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + invoiceId: String, + params: InvoiceUpdateParams = InvoiceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + invoiceId: String, + params: InvoiceUpdateParams = InvoiceUpdateParams.none(), + ): HttpResponseFor = update(invoiceId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -195,6 +317,16 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: InvoiceUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update(invoiceId: String, requestOptions: RequestOptions): HttpResponseFor = + update(invoiceId, InvoiceUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices`, but is otherwise the same as * [InvoiceService.list]. @@ -224,8 +356,24 @@ interface InvoiceService { * as [InvoiceService.fetch]. */ @MustBeClosed - fun fetch(params: InvoiceFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(invoiceId: String): HttpResponseFor = + fetch(invoiceId, InvoiceFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + invoiceId: String, + params: InvoiceFetchParams = InvoiceFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + invoiceId: String, + params: InvoiceFetchParams = InvoiceFetchParams.none(), + ): HttpResponseFor = fetch(invoiceId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -234,6 +382,16 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: InvoiceFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch(invoiceId: String, requestOptions: RequestOptions): HttpResponseFor = + fetch(invoiceId, InvoiceFetchParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /invoices/upcoming`, but is otherwise the same as * [InvoiceService.fetchUpcoming]. @@ -256,8 +414,24 @@ interface InvoiceService { * same as [InvoiceService.issue]. */ @MustBeClosed - fun issue(params: InvoiceIssueParams): HttpResponseFor = - issue(params, RequestOptions.none()) + fun issue(invoiceId: String): HttpResponseFor = + issue(invoiceId, InvoiceIssueParams.none()) + + /** @see [issue] */ + @MustBeClosed + fun issue( + invoiceId: String, + params: InvoiceIssueParams = InvoiceIssueParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + issue(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [issue] */ + @MustBeClosed + fun issue( + invoiceId: String, + params: InvoiceIssueParams = InvoiceIssueParams.none(), + ): HttpResponseFor = issue(invoiceId, params, RequestOptions.none()) /** @see [issue] */ @MustBeClosed @@ -266,11 +440,35 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [issue] */ + @MustBeClosed + fun issue(params: InvoiceIssueParams): HttpResponseFor = + issue(params, RequestOptions.none()) + + /** @see [issue] */ + @MustBeClosed + fun issue(invoiceId: String, requestOptions: RequestOptions): HttpResponseFor = + issue(invoiceId, InvoiceIssueParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /invoices/{invoice_id}/mark_paid`, but is otherwise * the same as [InvoiceService.markPaid]. */ @MustBeClosed + fun markPaid(invoiceId: String, params: InvoiceMarkPaidParams): HttpResponseFor = + markPaid(invoiceId, params, RequestOptions.none()) + + /** @see [markPaid] */ + @MustBeClosed + fun markPaid( + invoiceId: String, + params: InvoiceMarkPaidParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + markPaid(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [markPaid] */ + @MustBeClosed fun markPaid(params: InvoiceMarkPaidParams): HttpResponseFor = markPaid(params, RequestOptions.none()) @@ -286,8 +484,24 @@ interface InvoiceService { * same as [InvoiceService.pay]. */ @MustBeClosed - fun pay(params: InvoicePayParams): HttpResponseFor = - pay(params, RequestOptions.none()) + fun pay(invoiceId: String): HttpResponseFor = + pay(invoiceId, InvoicePayParams.none()) + + /** @see [pay] */ + @MustBeClosed + fun pay( + invoiceId: String, + params: InvoicePayParams = InvoicePayParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + pay(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [pay] */ + @MustBeClosed + fun pay( + invoiceId: String, + params: InvoicePayParams = InvoicePayParams.none(), + ): HttpResponseFor = pay(invoiceId, params, RequestOptions.none()) /** @see [pay] */ @MustBeClosed @@ -296,13 +510,39 @@ interface InvoiceService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [pay] */ + @MustBeClosed + fun pay(params: InvoicePayParams): HttpResponseFor = + pay(params, RequestOptions.none()) + + /** @see [pay] */ + @MustBeClosed + fun pay(invoiceId: String, requestOptions: RequestOptions): HttpResponseFor = + pay(invoiceId, InvoicePayParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /invoices/{invoice_id}/void`, but is otherwise the * same as [InvoiceService.voidInvoice]. */ @MustBeClosed - fun voidInvoice(params: InvoiceVoidInvoiceParams): HttpResponseFor = - voidInvoice(params, RequestOptions.none()) + fun voidInvoice(invoiceId: String): HttpResponseFor = + voidInvoice(invoiceId, InvoiceVoidInvoiceParams.none()) + + /** @see [voidInvoice] */ + @MustBeClosed + fun voidInvoice( + invoiceId: String, + params: InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + voidInvoice(params.toBuilder().invoiceId(invoiceId).build(), requestOptions) + + /** @see [voidInvoice] */ + @MustBeClosed + fun voidInvoice( + invoiceId: String, + params: InvoiceVoidInvoiceParams = InvoiceVoidInvoiceParams.none(), + ): HttpResponseFor = voidInvoice(invoiceId, params, RequestOptions.none()) /** @see [voidInvoice] */ @MustBeClosed @@ -310,5 +550,18 @@ interface InvoiceService { params: InvoiceVoidInvoiceParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [voidInvoice] */ + @MustBeClosed + fun voidInvoice(params: InvoiceVoidInvoiceParams): HttpResponseFor = + voidInvoice(params, RequestOptions.none()) + + /** @see [voidInvoice] */ + @MustBeClosed + fun voidInvoice( + invoiceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + voidInvoice(invoiceId, InvoiceVoidInvoiceParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt index 9ca3b288..54c0dc6c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/InvoiceServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -28,6 +29,7 @@ import com.withorb.api.models.InvoiceMarkPaidParams import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams import com.withorb.api.models.InvoiceVoidInvoiceParams +import kotlin.jvm.optionals.getOrNull class InvoiceServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvoiceService { @@ -119,6 +121,9 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO params: InvoiceUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -180,6 +185,9 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO params: InvoiceFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -233,6 +241,9 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO params: InvoiceIssueParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -260,6 +271,9 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO params: InvoiceMarkPaidParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -287,6 +301,9 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO params: InvoicePayParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -314,6 +331,9 @@ class InvoiceServiceImpl internal constructor(private val clientOptions: ClientO params: InvoiceVoidInvoiceParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("invoiceId", params.invoiceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt index df39426f..86faa1fd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemService.kt @@ -29,7 +29,18 @@ interface ItemService { ): Item /** This endpoint can be used to update properties on the Item. */ - fun update(params: ItemUpdateParams): Item = update(params, RequestOptions.none()) + fun update(itemId: String): Item = update(itemId, ItemUpdateParams.none()) + + /** @see [update] */ + fun update( + itemId: String, + params: ItemUpdateParams = ItemUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Item = update(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see [update] */ + fun update(itemId: String, params: ItemUpdateParams = ItemUpdateParams.none()): Item = + update(itemId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -37,6 +48,13 @@ interface ItemService { requestOptions: RequestOptions = RequestOptions.none(), ): Item + /** @see [update] */ + fun update(params: ItemUpdateParams): Item = update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(itemId: String, requestOptions: RequestOptions): Item = + update(itemId, ItemUpdateParams.none(), requestOptions) + /** This endpoint returns a list of all Items, ordered in descending order by creation time. */ fun list(): ItemListPage = list(ItemListParams.none()) @@ -55,11 +73,29 @@ interface ItemService { list(ItemListParams.none(), requestOptions) /** This endpoint returns an item identified by its item_id. */ - fun fetch(params: ItemFetchParams): Item = fetch(params, RequestOptions.none()) + fun fetch(itemId: String): Item = fetch(itemId, ItemFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + itemId: String, + params: ItemFetchParams = ItemFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Item = fetch(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch(itemId: String, params: ItemFetchParams = ItemFetchParams.none()): Item = + fetch(itemId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch(params: ItemFetchParams, requestOptions: RequestOptions = RequestOptions.none()): Item + /** @see [fetch] */ + fun fetch(params: ItemFetchParams): Item = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(itemId: String, requestOptions: RequestOptions): Item = + fetch(itemId, ItemFetchParams.none(), requestOptions) + /** A view of [ItemService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -83,8 +119,22 @@ interface ItemService { * [ItemService.update]. */ @MustBeClosed - fun update(params: ItemUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(itemId: String): HttpResponseFor = update(itemId, ItemUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + itemId: String, + params: ItemUpdateParams = ItemUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = update(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + itemId: String, + params: ItemUpdateParams = ItemUpdateParams.none(), + ): HttpResponseFor = update(itemId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -93,6 +143,16 @@ interface ItemService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: ItemUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update(itemId: String, requestOptions: RequestOptions): HttpResponseFor = + update(itemId, ItemUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /items`, but is otherwise the same as * [ItemService.list]. @@ -121,8 +181,22 @@ interface ItemService { * [ItemService.fetch]. */ @MustBeClosed - fun fetch(params: ItemFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(itemId: String): HttpResponseFor = fetch(itemId, ItemFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + itemId: String, + params: ItemFetchParams = ItemFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = fetch(params.toBuilder().itemId(itemId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + itemId: String, + params: ItemFetchParams = ItemFetchParams.none(), + ): HttpResponseFor = fetch(itemId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -130,5 +204,15 @@ interface ItemService { params: ItemFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: ItemFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch(itemId: String, requestOptions: RequestOptions): HttpResponseFor = + fetch(itemId, ItemFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt index 04065b32..a0a44bbb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/ItemServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -22,6 +23,7 @@ import com.withorb.api.models.ItemListPage import com.withorb.api.models.ItemListPageResponse import com.withorb.api.models.ItemListParams import com.withorb.api.models.ItemUpdateParams +import kotlin.jvm.optionals.getOrNull class ItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : ItemService { @@ -86,6 +88,9 @@ class ItemServiceImpl internal constructor(private val clientOptions: ClientOpti params: ItemUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("itemId", params.itemId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -147,6 +152,9 @@ class ItemServiceImpl internal constructor(private val clientOptions: ClientOpti params: ItemFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("itemId", params.itemId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt index 9042fb36..9c207ddb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricService.kt @@ -36,7 +36,20 @@ interface MetricService { * This endpoint allows you to update the `metadata` property on a metric. If you pass `null` * for the metadata value, it will clear any existing metadata for that invoice. */ - fun update(params: MetricUpdateParams): BillableMetric = update(params, RequestOptions.none()) + fun update(metricId: String): BillableMetric = update(metricId, MetricUpdateParams.none()) + + /** @see [update] */ + fun update( + metricId: String, + params: MetricUpdateParams = MetricUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BillableMetric = update(params.toBuilder().metricId(metricId).build(), requestOptions) + + /** @see [update] */ + fun update( + metricId: String, + params: MetricUpdateParams = MetricUpdateParams.none(), + ): BillableMetric = update(metricId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -44,6 +57,13 @@ interface MetricService { requestOptions: RequestOptions = RequestOptions.none(), ): BillableMetric + /** @see [update] */ + fun update(params: MetricUpdateParams): BillableMetric = update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(metricId: String, requestOptions: RequestOptions): BillableMetric = + update(metricId, MetricUpdateParams.none(), requestOptions) + /** * This endpoint is used to fetch [metric](/core-concepts##metric) details given a metric * identifier. It returns information about the metrics including its name, description, and @@ -69,7 +89,20 @@ interface MetricService { * This endpoint is used to list [metrics](/core-concepts#metric). It returns information about * the metrics including its name, description, and item. */ - fun fetch(params: MetricFetchParams): BillableMetric = fetch(params, RequestOptions.none()) + fun fetch(metricId: String): BillableMetric = fetch(metricId, MetricFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + metricId: String, + params: MetricFetchParams = MetricFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BillableMetric = fetch(params.toBuilder().metricId(metricId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + metricId: String, + params: MetricFetchParams = MetricFetchParams.none(), + ): BillableMetric = fetch(metricId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -77,6 +110,13 @@ interface MetricService { requestOptions: RequestOptions = RequestOptions.none(), ): BillableMetric + /** @see [fetch] */ + fun fetch(params: MetricFetchParams): BillableMetric = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(metricId: String, requestOptions: RequestOptions): BillableMetric = + fetch(metricId, MetricFetchParams.none(), requestOptions) + /** A view of [MetricService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -100,8 +140,24 @@ interface MetricService { * [MetricService.update]. */ @MustBeClosed - fun update(params: MetricUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(metricId: String): HttpResponseFor = + update(metricId, MetricUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + metricId: String, + params: MetricUpdateParams = MetricUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().metricId(metricId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + metricId: String, + params: MetricUpdateParams = MetricUpdateParams.none(), + ): HttpResponseFor = update(metricId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -110,6 +166,19 @@ interface MetricService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: MetricUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + metricId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(metricId, MetricUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /metrics`, but is otherwise the same as * [MetricService.list]. @@ -139,8 +208,24 @@ interface MetricService { * [MetricService.fetch]. */ @MustBeClosed - fun fetch(params: MetricFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(metricId: String): HttpResponseFor = + fetch(metricId, MetricFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + metricId: String, + params: MetricFetchParams = MetricFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().metricId(metricId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + metricId: String, + params: MetricFetchParams = MetricFetchParams.none(), + ): HttpResponseFor = fetch(metricId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -148,5 +233,18 @@ interface MetricService { params: MetricFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: MetricFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + metricId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + fetch(metricId, MetricFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt index cc6119c6..94d03141 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/MetricServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -22,6 +23,7 @@ import com.withorb.api.models.MetricListPage import com.withorb.api.models.MetricListPageResponse import com.withorb.api.models.MetricListParams import com.withorb.api.models.MetricUpdateParams +import kotlin.jvm.optionals.getOrNull class MetricServiceImpl internal constructor(private val clientOptions: ClientOptions) : MetricService { @@ -93,6 +95,9 @@ class MetricServiceImpl internal constructor(private val clientOptions: ClientOp params: MetricUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("metricId", params.metricId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -154,6 +159,9 @@ class MetricServiceImpl internal constructor(private val clientOptions: ClientOp params: MetricFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("metricId", params.metricId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 95f39fad..ea3405d5 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 @@ -37,7 +37,18 @@ interface PlanService { * * Other fields on a customer are currently immutable. */ - fun update(params: PlanUpdateParams): Plan = update(params, RequestOptions.none()) + fun update(planId: String): Plan = update(planId, PlanUpdateParams.none()) + + /** @see [update] */ + fun update( + planId: String, + params: PlanUpdateParams = PlanUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Plan = update(params.toBuilder().planId(planId).build(), requestOptions) + + /** @see [update] */ + fun update(planId: String, params: PlanUpdateParams = PlanUpdateParams.none()): Plan = + update(planId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -45,6 +56,13 @@ interface PlanService { requestOptions: RequestOptions = RequestOptions.none(), ): Plan + /** @see [update] */ + fun update(params: PlanUpdateParams): Plan = update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(planId: String, requestOptions: RequestOptions): Plan = + update(planId, PlanUpdateParams.none(), requestOptions) + /** * This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for an account in * a list format. The list of plans is ordered starting from the most recently created plan. The @@ -85,11 +103,29 @@ interface PlanService { * Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized * prices refer to all prices across all phases. */ - fun fetch(params: PlanFetchParams): Plan = fetch(params, RequestOptions.none()) + fun fetch(planId: String): Plan = fetch(planId, PlanFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + planId: String, + params: PlanFetchParams = PlanFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Plan = fetch(params.toBuilder().planId(planId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch(planId: String, params: PlanFetchParams = PlanFetchParams.none()): Plan = + fetch(planId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch(params: PlanFetchParams, requestOptions: RequestOptions = RequestOptions.none()): Plan + /** @see [fetch] */ + fun fetch(params: PlanFetchParams): Plan = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(planId: String, requestOptions: RequestOptions): Plan = + fetch(planId, PlanFetchParams.none(), requestOptions) + /** A view of [PlanService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -115,8 +151,22 @@ interface PlanService { * [PlanService.update]. */ @MustBeClosed - fun update(params: PlanUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(planId: String): HttpResponseFor = update(planId, PlanUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + planId: String, + params: PlanUpdateParams = PlanUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = update(params.toBuilder().planId(planId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + planId: String, + params: PlanUpdateParams = PlanUpdateParams.none(), + ): HttpResponseFor = update(planId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -125,6 +175,16 @@ interface PlanService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: PlanUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update(planId: String, requestOptions: RequestOptions): HttpResponseFor = + update(planId, PlanUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /plans`, but is otherwise the same as * [PlanService.list]. @@ -153,8 +213,22 @@ interface PlanService { * [PlanService.fetch]. */ @MustBeClosed - fun fetch(params: PlanFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(planId: String): HttpResponseFor = fetch(planId, PlanFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + planId: String, + params: PlanFetchParams = PlanFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = fetch(params.toBuilder().planId(planId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + planId: String, + params: PlanFetchParams = PlanFetchParams.none(), + ): HttpResponseFor = fetch(planId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -162,5 +236,15 @@ interface PlanService { params: PlanFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: PlanFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch(planId: String, requestOptions: RequestOptions): HttpResponseFor = + fetch(planId, PlanFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt index a817592d..ed66bd0c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PlanServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -24,6 +25,7 @@ import com.withorb.api.models.PlanListParams import com.withorb.api.models.PlanUpdateParams import com.withorb.api.services.blocking.plans.ExternalPlanIdService import com.withorb.api.services.blocking.plans.ExternalPlanIdServiceImpl +import kotlin.jvm.optionals.getOrNull class PlanServiceImpl internal constructor(private val clientOptions: ClientOptions) : PlanService { @@ -100,6 +102,9 @@ class PlanServiceImpl internal constructor(private val clientOptions: ClientOpti params: PlanUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("planId", params.planId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -161,6 +166,9 @@ class PlanServiceImpl internal constructor(private val clientOptions: ClientOpti params: PlanFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("planId", params.planId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt index 1648965a..1718a42e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceService.kt @@ -48,7 +48,18 @@ interface PriceService { * This endpoint allows you to update the `metadata` property on a price. If you pass null for * the metadata value, it will clear any existing metadata for that price. */ - fun update(params: PriceUpdateParams): Price = update(params, RequestOptions.none()) + fun update(priceId: String): Price = update(priceId, PriceUpdateParams.none()) + + /** @see [update] */ + fun update( + priceId: String, + params: PriceUpdateParams = PriceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = update(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [update] */ + fun update(priceId: String, params: PriceUpdateParams = PriceUpdateParams.none()): Price = + update(priceId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -56,6 +67,13 @@ interface PriceService { requestOptions: RequestOptions = RequestOptions.none(), ): Price + /** @see [update] */ + fun update(params: PriceUpdateParams): Price = update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(priceId: String, requestOptions: RequestOptions): Price = + update(priceId, PriceUpdateParams.none(), requestOptions) + /** * This endpoint is used to list all add-on prices created using the * [price creation endpoint](/api-reference/price/create-price). @@ -95,6 +113,17 @@ interface PriceService { * the results must be no greater than 1000. Note that this is a POST endpoint rather than a GET * endpoint because it employs a JSON body rather than query parameters. */ + fun evaluate(priceId: String, params: PriceEvaluateParams): PriceEvaluateResponse = + evaluate(priceId, params, RequestOptions.none()) + + /** @see [evaluate] */ + fun evaluate( + priceId: String, + params: PriceEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PriceEvaluateResponse = evaluate(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [evaluate] */ fun evaluate(params: PriceEvaluateParams): PriceEvaluateResponse = evaluate(params, RequestOptions.none()) @@ -105,7 +134,18 @@ interface PriceService { ): PriceEvaluateResponse /** This endpoint returns a price given an identifier. */ - fun fetch(params: PriceFetchParams): Price = fetch(params, RequestOptions.none()) + fun fetch(priceId: String): Price = fetch(priceId, PriceFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + priceId: String, + params: PriceFetchParams = PriceFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = fetch(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch(priceId: String, params: PriceFetchParams = PriceFetchParams.none()): Price = + fetch(priceId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -113,6 +153,13 @@ interface PriceService { requestOptions: RequestOptions = RequestOptions.none(), ): Price + /** @see [fetch] */ + fun fetch(params: PriceFetchParams): Price = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(priceId: String, requestOptions: RequestOptions): Price = + fetch(priceId, PriceFetchParams.none(), requestOptions) + /** A view of [PriceService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -138,8 +185,24 @@ interface PriceService { * [PriceService.update]. */ @MustBeClosed - fun update(params: PriceUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(priceId: String): HttpResponseFor = + update(priceId, PriceUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + priceId: String, + params: PriceUpdateParams = PriceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + priceId: String, + params: PriceUpdateParams = PriceUpdateParams.none(), + ): HttpResponseFor = update(priceId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -148,6 +211,16 @@ interface PriceService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: PriceUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update(priceId: String, requestOptions: RequestOptions): HttpResponseFor = + update(priceId, PriceUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /prices`, but is otherwise the same as * [PriceService.list]. @@ -176,6 +249,22 @@ interface PriceService { * same as [PriceService.evaluate]. */ @MustBeClosed + fun evaluate( + priceId: String, + params: PriceEvaluateParams, + ): HttpResponseFor = evaluate(priceId, params, RequestOptions.none()) + + /** @see [evaluate] */ + @MustBeClosed + fun evaluate( + priceId: String, + params: PriceEvaluateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + evaluate(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [evaluate] */ + @MustBeClosed fun evaluate(params: PriceEvaluateParams): HttpResponseFor = evaluate(params, RequestOptions.none()) @@ -191,8 +280,23 @@ interface PriceService { * [PriceService.fetch]. */ @MustBeClosed - fun fetch(params: PriceFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(priceId: String): HttpResponseFor = fetch(priceId, PriceFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + priceId: String, + params: PriceFetchParams = PriceFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().priceId(priceId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + priceId: String, + params: PriceFetchParams = PriceFetchParams.none(), + ): HttpResponseFor = fetch(priceId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -200,5 +304,15 @@ interface PriceService { params: PriceFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: PriceFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch(priceId: String, requestOptions: RequestOptions): HttpResponseFor = + fetch(priceId, PriceFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt index 556cb014..5f89789b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/PriceServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import com.withorb.api.models.PriceListParams import com.withorb.api.models.PriceUpdateParams import com.withorb.api.services.blocking.prices.ExternalPriceIdService import com.withorb.api.services.blocking.prices.ExternalPriceIdServiceImpl +import kotlin.jvm.optionals.getOrNull class PriceServiceImpl internal constructor(private val clientOptions: ClientOptions) : PriceService { @@ -110,6 +112,9 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt params: PriceUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("priceId", params.priceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -172,6 +177,9 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt params: PriceEvaluateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("priceId", params.priceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -199,6 +207,9 @@ class PriceServiceImpl internal constructor(private val clientOptions: ClientOpt params: PriceFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("priceId", params.priceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeService.kt index 13946e44..42a2deff 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeService.kt @@ -29,8 +29,26 @@ interface SubscriptionChangeService { * subscription change will be referenced by the `pending_subscription_change` field in the * response. */ - fun retrieve(params: SubscriptionChangeRetrieveParams): SubscriptionChangeRetrieveResponse = - retrieve(params, RequestOptions.none()) + fun retrieve(subscriptionChangeId: String): SubscriptionChangeRetrieveResponse = + retrieve(subscriptionChangeId, SubscriptionChangeRetrieveParams.none()) + + /** @see [retrieve] */ + fun retrieve( + subscriptionChangeId: String, + params: SubscriptionChangeRetrieveParams = SubscriptionChangeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionChangeRetrieveResponse = + retrieve( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [retrieve] */ + fun retrieve( + subscriptionChangeId: String, + params: SubscriptionChangeRetrieveParams = SubscriptionChangeRetrieveParams.none(), + ): SubscriptionChangeRetrieveResponse = + retrieve(subscriptionChangeId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -38,13 +56,38 @@ interface SubscriptionChangeService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionChangeRetrieveResponse + /** @see [retrieve] */ + fun retrieve(params: SubscriptionChangeRetrieveParams): SubscriptionChangeRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): SubscriptionChangeRetrieveResponse = + retrieve(subscriptionChangeId, SubscriptionChangeRetrieveParams.none(), requestOptions) + /** * Apply a subscription change to perform the intended action. If a positive amount is passed * with a request to this endpoint, any eligible invoices that were created will be issued * immediately if they only contain in-advance fees. */ - fun apply(params: SubscriptionChangeApplyParams): SubscriptionChangeApplyResponse = - apply(params, RequestOptions.none()) + fun apply(subscriptionChangeId: String): SubscriptionChangeApplyResponse = + apply(subscriptionChangeId, SubscriptionChangeApplyParams.none()) + + /** @see [apply] */ + fun apply( + subscriptionChangeId: String, + params: SubscriptionChangeApplyParams = SubscriptionChangeApplyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionChangeApplyResponse = + apply(params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), requestOptions) + + /** @see [apply] */ + fun apply( + subscriptionChangeId: String, + params: SubscriptionChangeApplyParams = SubscriptionChangeApplyParams.none(), + ): SubscriptionChangeApplyResponse = apply(subscriptionChangeId, params, RequestOptions.none()) /** @see [apply] */ fun apply( @@ -52,13 +95,42 @@ interface SubscriptionChangeService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionChangeApplyResponse + /** @see [apply] */ + fun apply(params: SubscriptionChangeApplyParams): SubscriptionChangeApplyResponse = + apply(params, RequestOptions.none()) + + /** @see [apply] */ + fun apply( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): SubscriptionChangeApplyResponse = + apply(subscriptionChangeId, SubscriptionChangeApplyParams.none(), requestOptions) + /** * Cancel a subscription change. The change can no longer be applied. A subscription can only * have one "pending" change at a time - use this endpoint to cancel an existing change before * creating a new one. */ - fun cancel(params: SubscriptionChangeCancelParams): SubscriptionChangeCancelResponse = - cancel(params, RequestOptions.none()) + fun cancel(subscriptionChangeId: String): SubscriptionChangeCancelResponse = + cancel(subscriptionChangeId, SubscriptionChangeCancelParams.none()) + + /** @see [cancel] */ + fun cancel( + subscriptionChangeId: String, + params: SubscriptionChangeCancelParams = SubscriptionChangeCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionChangeCancelResponse = + cancel( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [cancel] */ + fun cancel( + subscriptionChangeId: String, + params: SubscriptionChangeCancelParams = SubscriptionChangeCancelParams.none(), + ): SubscriptionChangeCancelResponse = + cancel(subscriptionChangeId, params, RequestOptions.none()) /** @see [cancel] */ fun cancel( @@ -66,6 +138,17 @@ interface SubscriptionChangeService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionChangeCancelResponse + /** @see [cancel] */ + fun cancel(params: SubscriptionChangeCancelParams): SubscriptionChangeCancelResponse = + cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + fun cancel( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): SubscriptionChangeCancelResponse = + cancel(subscriptionChangeId, SubscriptionChangeCancelParams.none(), requestOptions) + /** * A view of [SubscriptionChangeService] that provides access to raw HTTP responses for each * method. @@ -78,9 +161,29 @@ interface SubscriptionChangeService { */ @MustBeClosed fun retrieve( - params: SubscriptionChangeRetrieveParams + subscriptionChangeId: String ): HttpResponseFor = - retrieve(params, RequestOptions.none()) + retrieve(subscriptionChangeId, SubscriptionChangeRetrieveParams.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + subscriptionChangeId: String, + params: SubscriptionChangeRetrieveParams = SubscriptionChangeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + subscriptionChangeId: String, + params: SubscriptionChangeRetrieveParams = SubscriptionChangeRetrieveParams.none(), + ): HttpResponseFor = + retrieve(subscriptionChangeId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -89,15 +192,49 @@ interface SubscriptionChangeService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: SubscriptionChangeRetrieveParams + ): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(subscriptionChangeId, SubscriptionChangeRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /subscription_changes/{subscription_change_id}/apply`, but is otherwise the same as * [SubscriptionChangeService.apply]. */ @MustBeClosed + fun apply(subscriptionChangeId: String): HttpResponseFor = + apply(subscriptionChangeId, SubscriptionChangeApplyParams.none()) + + /** @see [apply] */ + @MustBeClosed fun apply( - params: SubscriptionChangeApplyParams - ): HttpResponseFor = apply(params, RequestOptions.none()) + subscriptionChangeId: String, + params: SubscriptionChangeApplyParams = SubscriptionChangeApplyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + apply( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [apply] */ + @MustBeClosed + fun apply( + subscriptionChangeId: String, + params: SubscriptionChangeApplyParams = SubscriptionChangeApplyParams.none(), + ): HttpResponseFor = + apply(subscriptionChangeId, params, RequestOptions.none()) /** @see [apply] */ @MustBeClosed @@ -106,6 +243,20 @@ interface SubscriptionChangeService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [apply] */ + @MustBeClosed + fun apply( + params: SubscriptionChangeApplyParams + ): HttpResponseFor = apply(params, RequestOptions.none()) + + /** @see [apply] */ + @MustBeClosed + fun apply( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + apply(subscriptionChangeId, SubscriptionChangeApplyParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /subscription_changes/{subscription_change_id}/cancel`, but is otherwise the same as @@ -113,8 +264,29 @@ interface SubscriptionChangeService { */ @MustBeClosed fun cancel( - params: SubscriptionChangeCancelParams - ): HttpResponseFor = cancel(params, RequestOptions.none()) + subscriptionChangeId: String + ): HttpResponseFor = + cancel(subscriptionChangeId, SubscriptionChangeCancelParams.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + subscriptionChangeId: String, + params: SubscriptionChangeCancelParams = SubscriptionChangeCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel( + params.toBuilder().subscriptionChangeId(subscriptionChangeId).build(), + requestOptions, + ) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + subscriptionChangeId: String, + params: SubscriptionChangeCancelParams = SubscriptionChangeCancelParams.none(), + ): HttpResponseFor = + cancel(subscriptionChangeId, params, RequestOptions.none()) /** @see [cancel] */ @MustBeClosed @@ -122,5 +294,19 @@ interface SubscriptionChangeService { params: SubscriptionChangeCancelParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + params: SubscriptionChangeCancelParams + ): HttpResponseFor = cancel(params, RequestOptions.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + subscriptionChangeId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + cancel(subscriptionChangeId, SubscriptionChangeCancelParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceImpl.kt index 87fd8858..b103be4a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionChangeServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -21,6 +22,7 @@ import com.withorb.api.models.SubscriptionChangeCancelParams import com.withorb.api.models.SubscriptionChangeCancelResponse import com.withorb.api.models.SubscriptionChangeRetrieveParams import com.withorb.api.models.SubscriptionChangeRetrieveResponse +import kotlin.jvm.optionals.getOrNull class SubscriptionChangeServiceImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionChangeService { @@ -65,6 +67,9 @@ class SubscriptionChangeServiceImpl internal constructor(private val clientOptio params: SubscriptionChangeRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionChangeId", params.subscriptionChangeId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -92,6 +97,9 @@ class SubscriptionChangeServiceImpl internal constructor(private val clientOptio params: SubscriptionChangeApplyParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionChangeId", params.subscriptionChangeId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -120,6 +128,9 @@ class SubscriptionChangeServiceImpl internal constructor(private val clientOptio params: SubscriptionChangeCancelParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionChangeId", params.subscriptionChangeId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) 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 b8ea48c3..337953b2 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 @@ -303,8 +303,22 @@ interface SubscriptionService { * This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, * `invoicing_threshold`, and `default_invoice_memo` properties on a subscription. */ - fun update(params: SubscriptionUpdateParams): Subscription = - update(params, RequestOptions.none()) + fun update(subscriptionId: String): Subscription = + update(subscriptionId, SubscriptionUpdateParams.none()) + + /** @see [update] */ + fun update( + subscriptionId: String, + params: SubscriptionUpdateParams = SubscriptionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Subscription = + update(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [update] */ + fun update( + subscriptionId: String, + params: SubscriptionUpdateParams = SubscriptionUpdateParams.none(), + ): Subscription = update(subscriptionId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -312,6 +326,14 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): Subscription + /** @see [update] */ + fun update(params: SubscriptionUpdateParams): Subscription = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(subscriptionId: String, requestOptions: RequestOptions): Subscription = + update(subscriptionId, SubscriptionUpdateParams.none(), requestOptions) + /** * This endpoint returns a list of all subscriptions for an account as a * [paginated](/api-reference/pagination) list, ordered starting from the most recently created @@ -391,6 +413,20 @@ interface SubscriptionService { * invoice and generate a new one based on the new dates for the subscription. See the section * on [cancellation behaviors](/product-catalog/creating-subscriptions#cancellation-behaviors). */ + fun cancel( + subscriptionId: String, + params: SubscriptionCancelParams, + ): SubscriptionCancelResponse = cancel(subscriptionId, params, RequestOptions.none()) + + /** @see [cancel] */ + fun cancel( + subscriptionId: String, + params: SubscriptionCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionCancelResponse = + cancel(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [cancel] */ fun cancel(params: SubscriptionCancelParams): SubscriptionCancelResponse = cancel(params, RequestOptions.none()) @@ -404,7 +440,22 @@ interface SubscriptionService { * This endpoint is used to fetch a [Subscription](/core-concepts##subscription) given an * identifier. */ - fun fetch(params: SubscriptionFetchParams): Subscription = fetch(params, RequestOptions.none()) + fun fetch(subscriptionId: String): Subscription = + fetch(subscriptionId, SubscriptionFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + subscriptionId: String, + params: SubscriptionFetchParams = SubscriptionFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Subscription = + fetch(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + subscriptionId: String, + params: SubscriptionFetchParams = SubscriptionFetchParams.none(), + ): Subscription = fetch(subscriptionId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -412,6 +463,13 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): Subscription + /** @see [fetch] */ + fun fetch(params: SubscriptionFetchParams): Subscription = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(subscriptionId: String, requestOptions: RequestOptions): Subscription = + fetch(subscriptionId, SubscriptionFetchParams.none(), requestOptions) + /** * This endpoint is used to fetch a day-by-day snapshot of a subscription's costs in Orb, * calculated by applying pricing information to the underlying usage (see the @@ -423,8 +481,22 @@ interface SubscriptionService { * of costs to a specific subscription for the customer (e.g. to de-aggregate costs when a * customer's subscription has started and stopped on the same day). */ - fun fetchCosts(params: SubscriptionFetchCostsParams): SubscriptionFetchCostsResponse = - fetchCosts(params, RequestOptions.none()) + fun fetchCosts(subscriptionId: String): SubscriptionFetchCostsResponse = + fetchCosts(subscriptionId, SubscriptionFetchCostsParams.none()) + + /** @see [fetchCosts] */ + fun fetchCosts( + subscriptionId: String, + params: SubscriptionFetchCostsParams = SubscriptionFetchCostsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionFetchCostsResponse = + fetchCosts(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchCosts] */ + fun fetchCosts( + subscriptionId: String, + params: SubscriptionFetchCostsParams = SubscriptionFetchCostsParams.none(), + ): SubscriptionFetchCostsResponse = fetchCosts(subscriptionId, params, RequestOptions.none()) /** @see [fetchCosts] */ fun fetchCosts( @@ -432,13 +504,38 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionFetchCostsResponse + /** @see [fetchCosts] */ + fun fetchCosts(params: SubscriptionFetchCostsParams): SubscriptionFetchCostsResponse = + fetchCosts(params, RequestOptions.none()) + + /** @see [fetchCosts] */ + fun fetchCosts( + subscriptionId: String, + requestOptions: RequestOptions, + ): SubscriptionFetchCostsResponse = + fetchCosts(subscriptionId, SubscriptionFetchCostsParams.none(), requestOptions) + /** * This endpoint returns a [paginated](/api-reference/pagination) list of all plans associated * with a subscription along with their start and end dates. This list contains the * subscription's initial plan along with past and future plan changes. */ - fun fetchSchedule(params: SubscriptionFetchScheduleParams): SubscriptionFetchSchedulePage = - fetchSchedule(params, RequestOptions.none()) + fun fetchSchedule(subscriptionId: String): SubscriptionFetchSchedulePage = + fetchSchedule(subscriptionId, SubscriptionFetchScheduleParams.none()) + + /** @see [fetchSchedule] */ + fun fetchSchedule( + subscriptionId: String, + params: SubscriptionFetchScheduleParams = SubscriptionFetchScheduleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionFetchSchedulePage = + fetchSchedule(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchSchedule] */ + fun fetchSchedule( + subscriptionId: String, + params: SubscriptionFetchScheduleParams = SubscriptionFetchScheduleParams.none(), + ): SubscriptionFetchSchedulePage = fetchSchedule(subscriptionId, params, RequestOptions.none()) /** @see [fetchSchedule] */ fun fetchSchedule( @@ -446,6 +543,17 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionFetchSchedulePage + /** @see [fetchSchedule] */ + fun fetchSchedule(params: SubscriptionFetchScheduleParams): SubscriptionFetchSchedulePage = + fetchSchedule(params, RequestOptions.none()) + + /** @see [fetchSchedule] */ + fun fetchSchedule( + subscriptionId: String, + requestOptions: RequestOptions, + ): SubscriptionFetchSchedulePage = + fetchSchedule(subscriptionId, SubscriptionFetchScheduleParams.none(), requestOptions) + /** * This endpoint is used to fetch a subscription's usage in Orb. Especially when combined with * optional query parameters, this endpoint is a powerful way to build visualizations on top of @@ -623,8 +731,22 @@ interface SubscriptionService { * - `second_dimension_key`: `provider` * - `second_dimension_value`: `aws` */ - fun fetchUsage(params: SubscriptionFetchUsageParams): SubscriptionUsage = - fetchUsage(params, RequestOptions.none()) + fun fetchUsage(subscriptionId: String): SubscriptionUsage = + fetchUsage(subscriptionId, SubscriptionFetchUsageParams.none()) + + /** @see [fetchUsage] */ + fun fetchUsage( + subscriptionId: String, + params: SubscriptionFetchUsageParams = SubscriptionFetchUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionUsage = + fetchUsage(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchUsage] */ + fun fetchUsage( + subscriptionId: String, + params: SubscriptionFetchUsageParams = SubscriptionFetchUsageParams.none(), + ): SubscriptionUsage = fetchUsage(subscriptionId, params, RequestOptions.none()) /** @see [fetchUsage] */ fun fetchUsage( @@ -632,6 +754,14 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionUsage + /** @see [fetchUsage] */ + fun fetchUsage(params: SubscriptionFetchUsageParams): SubscriptionUsage = + fetchUsage(params, RequestOptions.none()) + + /** @see [fetchUsage] */ + fun fetchUsage(subscriptionId: String, requestOptions: RequestOptions): SubscriptionUsage = + fetchUsage(subscriptionId, SubscriptionFetchUsageParams.none(), requestOptions) + /** * This endpoint is used to add and edit subscription * [price intervals](/api-reference/price-interval/add-or-edit-price-intervals). By making @@ -699,9 +829,23 @@ interface SubscriptionService { * using the `fixed_fee_quantity_transitions` property on a subscription’s serialized price * intervals. */ + fun priceIntervals(subscriptionId: String): SubscriptionPriceIntervalsResponse = + priceIntervals(subscriptionId, SubscriptionPriceIntervalsParams.none()) + + /** @see [priceIntervals] */ fun priceIntervals( - params: SubscriptionPriceIntervalsParams - ): SubscriptionPriceIntervalsResponse = priceIntervals(params, RequestOptions.none()) + subscriptionId: String, + params: SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionPriceIntervalsResponse = + priceIntervals(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [priceIntervals] */ + fun priceIntervals( + subscriptionId: String, + params: SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams.none(), + ): SubscriptionPriceIntervalsResponse = + priceIntervals(subscriptionId, params, RequestOptions.none()) /** @see [priceIntervals] */ fun priceIntervals( @@ -709,6 +853,18 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionPriceIntervalsResponse + /** @see [priceIntervals] */ + fun priceIntervals( + params: SubscriptionPriceIntervalsParams + ): SubscriptionPriceIntervalsResponse = priceIntervals(params, RequestOptions.none()) + + /** @see [priceIntervals] */ + fun priceIntervals( + subscriptionId: String, + requestOptions: RequestOptions, + ): SubscriptionPriceIntervalsResponse = + priceIntervals(subscriptionId, SubscriptionPriceIntervalsParams.none(), requestOptions) + /** * This endpoint can be used to change an existing subscription's plan. It returns the * serialized updated subscription object. @@ -875,6 +1031,24 @@ interface SubscriptionService { * change, adjusting the customer balance as needed. For details on this behavior, see * [Modifying subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). */ + fun schedulePlanChange( + subscriptionId: String, + params: SubscriptionSchedulePlanChangeParams, + ): SubscriptionSchedulePlanChangeResponse = + schedulePlanChange(subscriptionId, params, RequestOptions.none()) + + /** @see [schedulePlanChange] */ + fun schedulePlanChange( + subscriptionId: String, + params: SubscriptionSchedulePlanChangeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionSchedulePlanChangeResponse = + schedulePlanChange( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [schedulePlanChange] */ fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams ): SubscriptionSchedulePlanChangeResponse = schedulePlanChange(params, RequestOptions.none()) @@ -888,8 +1062,23 @@ interface SubscriptionService { /** * Manually trigger a phase, effective the given date (or the current time, if not specified). */ - fun triggerPhase(params: SubscriptionTriggerPhaseParams): SubscriptionTriggerPhaseResponse = - triggerPhase(params, RequestOptions.none()) + fun triggerPhase(subscriptionId: String): SubscriptionTriggerPhaseResponse = + triggerPhase(subscriptionId, SubscriptionTriggerPhaseParams.none()) + + /** @see [triggerPhase] */ + fun triggerPhase( + subscriptionId: String, + params: SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionTriggerPhaseResponse = + triggerPhase(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [triggerPhase] */ + fun triggerPhase( + subscriptionId: String, + params: SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams.none(), + ): SubscriptionTriggerPhaseResponse = + triggerPhase(subscriptionId, params, RequestOptions.none()) /** @see [triggerPhase] */ fun triggerPhase( @@ -897,6 +1086,17 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionTriggerPhaseResponse + /** @see [triggerPhase] */ + fun triggerPhase(params: SubscriptionTriggerPhaseParams): SubscriptionTriggerPhaseResponse = + triggerPhase(params, RequestOptions.none()) + + /** @see [triggerPhase] */ + fun triggerPhase( + subscriptionId: String, + requestOptions: RequestOptions, + ): SubscriptionTriggerPhaseResponse = + triggerPhase(subscriptionId, SubscriptionTriggerPhaseParams.none(), requestOptions) + /** * This endpoint can be used to unschedule any pending cancellations for a subscription. * @@ -904,10 +1104,28 @@ interface SubscriptionService { * This operation will turn on auto-renew, ensuring that the subscription does not end at the * currently scheduled cancellation time. */ + fun unscheduleCancellation(subscriptionId: String): SubscriptionUnscheduleCancellationResponse = + unscheduleCancellation(subscriptionId, SubscriptionUnscheduleCancellationParams.none()) + + /** @see [unscheduleCancellation] */ fun unscheduleCancellation( - params: SubscriptionUnscheduleCancellationParams + subscriptionId: String, + params: SubscriptionUnscheduleCancellationParams = + SubscriptionUnscheduleCancellationParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionUnscheduleCancellationResponse = - unscheduleCancellation(params, RequestOptions.none()) + unscheduleCancellation( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unscheduleCancellation] */ + fun unscheduleCancellation( + subscriptionId: String, + params: SubscriptionUnscheduleCancellationParams = + SubscriptionUnscheduleCancellationParams.none(), + ): SubscriptionUnscheduleCancellationResponse = + unscheduleCancellation(subscriptionId, params, RequestOptions.none()) /** @see [unscheduleCancellation] */ fun unscheduleCancellation( @@ -915,12 +1133,47 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionUnscheduleCancellationResponse + /** @see [unscheduleCancellation] */ + fun unscheduleCancellation( + params: SubscriptionUnscheduleCancellationParams + ): SubscriptionUnscheduleCancellationResponse = + unscheduleCancellation(params, RequestOptions.none()) + + /** @see [unscheduleCancellation] */ + fun unscheduleCancellation( + subscriptionId: String, + requestOptions: RequestOptions, + ): SubscriptionUnscheduleCancellationResponse = + unscheduleCancellation( + subscriptionId, + SubscriptionUnscheduleCancellationParams.none(), + requestOptions, + ) + /** * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. * * If there are no updates scheduled, a request validation error will be returned with a 400 * status code. */ + fun unscheduleFixedFeeQuantityUpdates( + subscriptionId: String, + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + ): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = + unscheduleFixedFeeQuantityUpdates(subscriptionId, params, RequestOptions.none()) + + /** @see [unscheduleFixedFeeQuantityUpdates] */ + fun unscheduleFixedFeeQuantityUpdates( + subscriptionId: String, + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = + unscheduleFixedFeeQuantityUpdates( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unscheduleFixedFeeQuantityUpdates] */ fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams ): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = @@ -936,9 +1189,32 @@ interface SubscriptionService { * This endpoint can be used to unschedule any pending plan changes on an existing subscription. */ fun unschedulePendingPlanChanges( - params: SubscriptionUnschedulePendingPlanChangesParams + subscriptionId: String ): SubscriptionUnschedulePendingPlanChangesResponse = - unschedulePendingPlanChanges(params, RequestOptions.none()) + unschedulePendingPlanChanges( + subscriptionId, + SubscriptionUnschedulePendingPlanChangesParams.none(), + ) + + /** @see [unschedulePendingPlanChanges] */ + fun unschedulePendingPlanChanges( + subscriptionId: String, + params: SubscriptionUnschedulePendingPlanChangesParams = + SubscriptionUnschedulePendingPlanChangesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionUnschedulePendingPlanChangesResponse = + unschedulePendingPlanChanges( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unschedulePendingPlanChanges] */ + fun unschedulePendingPlanChanges( + subscriptionId: String, + params: SubscriptionUnschedulePendingPlanChangesParams = + SubscriptionUnschedulePendingPlanChangesParams.none(), + ): SubscriptionUnschedulePendingPlanChangesResponse = + unschedulePendingPlanChanges(subscriptionId, params, RequestOptions.none()) /** @see [unschedulePendingPlanChanges] */ fun unschedulePendingPlanChanges( @@ -946,6 +1222,23 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): SubscriptionUnschedulePendingPlanChangesResponse + /** @see [unschedulePendingPlanChanges] */ + fun unschedulePendingPlanChanges( + params: SubscriptionUnschedulePendingPlanChangesParams + ): SubscriptionUnschedulePendingPlanChangesResponse = + unschedulePendingPlanChanges(params, RequestOptions.none()) + + /** @see [unschedulePendingPlanChanges] */ + fun unschedulePendingPlanChanges( + subscriptionId: String, + requestOptions: RequestOptions, + ): SubscriptionUnschedulePendingPlanChangesResponse = + unschedulePendingPlanChanges( + subscriptionId, + SubscriptionUnschedulePendingPlanChangesParams.none(), + requestOptions, + ) + /** * This endpoint can be used to update the quantity for a fixed fee. * @@ -960,6 +1253,24 @@ interface SubscriptionService { * If the fee is an in-advance fixed fee, it will also issue an immediate invoice for the * difference for the remainder of the billing period. */ + fun updateFixedFeeQuantity( + subscriptionId: String, + params: SubscriptionUpdateFixedFeeQuantityParams, + ): SubscriptionUpdateFixedFeeQuantityResponse = + updateFixedFeeQuantity(subscriptionId, params, RequestOptions.none()) + + /** @see [updateFixedFeeQuantity] */ + fun updateFixedFeeQuantity( + subscriptionId: String, + params: SubscriptionUpdateFixedFeeQuantityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionUpdateFixedFeeQuantityResponse = + updateFixedFeeQuantity( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [updateFixedFeeQuantity] */ fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams ): SubscriptionUpdateFixedFeeQuantityResponse = @@ -989,6 +1300,20 @@ interface SubscriptionService { * scheduled or an add-on price was added, that change will be pushed back by the same amount of * time the trial is extended). */ + fun updateTrial( + subscriptionId: String, + params: SubscriptionUpdateTrialParams, + ): SubscriptionUpdateTrialResponse = updateTrial(subscriptionId, params, RequestOptions.none()) + + /** @see [updateTrial] */ + fun updateTrial( + subscriptionId: String, + params: SubscriptionUpdateTrialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionUpdateTrialResponse = + updateTrial(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [updateTrial] */ fun updateTrial(params: SubscriptionUpdateTrialParams): SubscriptionUpdateTrialResponse = updateTrial(params, RequestOptions.none()) @@ -1034,8 +1359,24 @@ interface SubscriptionService { * the same as [SubscriptionService.update]. */ @MustBeClosed - fun update(params: SubscriptionUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(subscriptionId: String): HttpResponseFor = + update(subscriptionId, SubscriptionUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + subscriptionId: String, + params: SubscriptionUpdateParams = SubscriptionUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + subscriptionId: String, + params: SubscriptionUpdateParams = SubscriptionUpdateParams.none(), + ): HttpResponseFor = update(subscriptionId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -1044,6 +1385,19 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: SubscriptionUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + subscriptionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(subscriptionId, SubscriptionUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /subscriptions`, but is otherwise the same as * [SubscriptionService.list]. @@ -1074,6 +1428,23 @@ interface SubscriptionService { * otherwise the same as [SubscriptionService.cancel]. */ @MustBeClosed + fun cancel( + subscriptionId: String, + params: SubscriptionCancelParams, + ): HttpResponseFor = + cancel(subscriptionId, params, RequestOptions.none()) + + /** @see [cancel] */ + @MustBeClosed + fun cancel( + subscriptionId: String, + params: SubscriptionCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [cancel] */ + @MustBeClosed fun cancel(params: SubscriptionCancelParams): HttpResponseFor = cancel(params, RequestOptions.none()) @@ -1089,8 +1460,24 @@ interface SubscriptionService { * the same as [SubscriptionService.fetch]. */ @MustBeClosed - fun fetch(params: SubscriptionFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(subscriptionId: String): HttpResponseFor = + fetch(subscriptionId, SubscriptionFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + subscriptionId: String, + params: SubscriptionFetchParams = SubscriptionFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + subscriptionId: String, + params: SubscriptionFetchParams = SubscriptionFetchParams.none(), + ): HttpResponseFor = fetch(subscriptionId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -1099,15 +1486,43 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: SubscriptionFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + subscriptionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + fetch(subscriptionId, SubscriptionFetchParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/costs`, but is * otherwise the same as [SubscriptionService.fetchCosts]. */ @MustBeClosed + fun fetchCosts(subscriptionId: String): HttpResponseFor = + fetchCosts(subscriptionId, SubscriptionFetchCostsParams.none()) + + /** @see [fetchCosts] */ + @MustBeClosed fun fetchCosts( - params: SubscriptionFetchCostsParams + subscriptionId: String, + params: SubscriptionFetchCostsParams = SubscriptionFetchCostsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = - fetchCosts(params, RequestOptions.none()) + fetchCosts(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchCosts] */ + @MustBeClosed + fun fetchCosts( + subscriptionId: String, + params: SubscriptionFetchCostsParams = SubscriptionFetchCostsParams.none(), + ): HttpResponseFor = + fetchCosts(subscriptionId, params, RequestOptions.none()) /** @see [fetchCosts] */ @MustBeClosed @@ -1116,15 +1531,45 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [fetchCosts] */ + @MustBeClosed + fun fetchCosts( + params: SubscriptionFetchCostsParams + ): HttpResponseFor = + fetchCosts(params, RequestOptions.none()) + + /** @see [fetchCosts] */ + @MustBeClosed + fun fetchCosts( + subscriptionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + fetchCosts(subscriptionId, SubscriptionFetchCostsParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/schedule`, but is * otherwise the same as [SubscriptionService.fetchSchedule]. */ @MustBeClosed + fun fetchSchedule(subscriptionId: String): HttpResponseFor = + fetchSchedule(subscriptionId, SubscriptionFetchScheduleParams.none()) + + /** @see [fetchSchedule] */ + @MustBeClosed fun fetchSchedule( - params: SubscriptionFetchScheduleParams + subscriptionId: String, + params: SubscriptionFetchScheduleParams = SubscriptionFetchScheduleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = - fetchSchedule(params, RequestOptions.none()) + fetchSchedule(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchSchedule] */ + @MustBeClosed + fun fetchSchedule( + subscriptionId: String, + params: SubscriptionFetchScheduleParams = SubscriptionFetchScheduleParams.none(), + ): HttpResponseFor = + fetchSchedule(subscriptionId, params, RequestOptions.none()) /** @see [fetchSchedule] */ @MustBeClosed @@ -1133,13 +1578,45 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [fetchSchedule] */ + @MustBeClosed + fun fetchSchedule( + params: SubscriptionFetchScheduleParams + ): HttpResponseFor = + fetchSchedule(params, RequestOptions.none()) + + /** @see [fetchSchedule] */ + @MustBeClosed + fun fetchSchedule( + subscriptionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + fetchSchedule(subscriptionId, SubscriptionFetchScheduleParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /subscriptions/{subscription_id}/usage`, but is * otherwise the same as [SubscriptionService.fetchUsage]. */ @MustBeClosed - fun fetchUsage(params: SubscriptionFetchUsageParams): HttpResponseFor = - fetchUsage(params, RequestOptions.none()) + fun fetchUsage(subscriptionId: String): HttpResponseFor = + fetchUsage(subscriptionId, SubscriptionFetchUsageParams.none()) + + /** @see [fetchUsage] */ + @MustBeClosed + fun fetchUsage( + subscriptionId: String, + params: SubscriptionFetchUsageParams = SubscriptionFetchUsageParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetchUsage(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [fetchUsage] */ + @MustBeClosed + fun fetchUsage( + subscriptionId: String, + params: SubscriptionFetchUsageParams = SubscriptionFetchUsageParams.none(), + ): HttpResponseFor = + fetchUsage(subscriptionId, params, RequestOptions.none()) /** @see [fetchUsage] */ @MustBeClosed @@ -1148,15 +1625,48 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [fetchUsage] */ + @MustBeClosed + fun fetchUsage(params: SubscriptionFetchUsageParams): HttpResponseFor = + fetchUsage(params, RequestOptions.none()) + + /** @see [fetchUsage] */ + @MustBeClosed + fun fetchUsage( + subscriptionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + fetchUsage(subscriptionId, SubscriptionFetchUsageParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /subscriptions/{subscription_id}/price_intervals`, * but is otherwise the same as [SubscriptionService.priceIntervals]. */ @MustBeClosed fun priceIntervals( - params: SubscriptionPriceIntervalsParams + subscriptionId: String ): HttpResponseFor = - priceIntervals(params, RequestOptions.none()) + priceIntervals(subscriptionId, SubscriptionPriceIntervalsParams.none()) + + /** @see [priceIntervals] */ + @MustBeClosed + fun priceIntervals( + subscriptionId: String, + params: SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + priceIntervals( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [priceIntervals] */ + @MustBeClosed + fun priceIntervals( + subscriptionId: String, + params: SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams.none(), + ): HttpResponseFor = + priceIntervals(subscriptionId, params, RequestOptions.none()) /** @see [priceIntervals] */ @MustBeClosed @@ -1165,12 +1675,47 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [priceIntervals] */ + @MustBeClosed + fun priceIntervals( + params: SubscriptionPriceIntervalsParams + ): HttpResponseFor = + priceIntervals(params, RequestOptions.none()) + + /** @see [priceIntervals] */ + @MustBeClosed + fun priceIntervals( + subscriptionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + priceIntervals(subscriptionId, SubscriptionPriceIntervalsParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /subscriptions/{subscription_id}/schedule_plan_change`, but is otherwise the same as * [SubscriptionService.schedulePlanChange]. */ @MustBeClosed + fun schedulePlanChange( + subscriptionId: String, + params: SubscriptionSchedulePlanChangeParams, + ): HttpResponseFor = + schedulePlanChange(subscriptionId, params, RequestOptions.none()) + + /** @see [schedulePlanChange] */ + @MustBeClosed + fun schedulePlanChange( + subscriptionId: String, + params: SubscriptionSchedulePlanChangeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + schedulePlanChange( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [schedulePlanChange] */ + @MustBeClosed fun schedulePlanChange( params: SubscriptionSchedulePlanChangeParams ): HttpResponseFor = @@ -1189,9 +1734,26 @@ interface SubscriptionService { */ @MustBeClosed fun triggerPhase( - params: SubscriptionTriggerPhaseParams + subscriptionId: String ): HttpResponseFor = - triggerPhase(params, RequestOptions.none()) + triggerPhase(subscriptionId, SubscriptionTriggerPhaseParams.none()) + + /** @see [triggerPhase] */ + @MustBeClosed + fun triggerPhase( + subscriptionId: String, + params: SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + triggerPhase(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [triggerPhase] */ + @MustBeClosed + fun triggerPhase( + subscriptionId: String, + params: SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams.none(), + ): HttpResponseFor = + triggerPhase(subscriptionId, params, RequestOptions.none()) /** @see [triggerPhase] */ @MustBeClosed @@ -1200,6 +1762,21 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [triggerPhase] */ + @MustBeClosed + fun triggerPhase( + params: SubscriptionTriggerPhaseParams + ): HttpResponseFor = + triggerPhase(params, RequestOptions.none()) + + /** @see [triggerPhase] */ + @MustBeClosed + fun triggerPhase( + subscriptionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + triggerPhase(subscriptionId, SubscriptionTriggerPhaseParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /subscriptions/{subscription_id}/unschedule_cancellation`, but is otherwise the same as @@ -1207,9 +1784,31 @@ interface SubscriptionService { */ @MustBeClosed fun unscheduleCancellation( - params: SubscriptionUnscheduleCancellationParams + subscriptionId: String ): HttpResponseFor = - unscheduleCancellation(params, RequestOptions.none()) + unscheduleCancellation(subscriptionId, SubscriptionUnscheduleCancellationParams.none()) + + /** @see [unscheduleCancellation] */ + @MustBeClosed + fun unscheduleCancellation( + subscriptionId: String, + params: SubscriptionUnscheduleCancellationParams = + SubscriptionUnscheduleCancellationParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + unscheduleCancellation( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unscheduleCancellation] */ + @MustBeClosed + fun unscheduleCancellation( + subscriptionId: String, + params: SubscriptionUnscheduleCancellationParams = + SubscriptionUnscheduleCancellationParams.none(), + ): HttpResponseFor = + unscheduleCancellation(subscriptionId, params, RequestOptions.none()) /** @see [unscheduleCancellation] */ @MustBeClosed @@ -1218,12 +1817,51 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [unscheduleCancellation] */ + @MustBeClosed + fun unscheduleCancellation( + params: SubscriptionUnscheduleCancellationParams + ): HttpResponseFor = + unscheduleCancellation(params, RequestOptions.none()) + + /** @see [unscheduleCancellation] */ + @MustBeClosed + fun unscheduleCancellation( + subscriptionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + unscheduleCancellation( + subscriptionId, + SubscriptionUnscheduleCancellationParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `post * /subscriptions/{subscription_id}/unschedule_fixed_fee_quantity_updates`, but is otherwise * the same as [SubscriptionService.unscheduleFixedFeeQuantityUpdates]. */ @MustBeClosed + fun unscheduleFixedFeeQuantityUpdates( + subscriptionId: String, + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + ): HttpResponseFor = + unscheduleFixedFeeQuantityUpdates(subscriptionId, params, RequestOptions.none()) + + /** @see [unscheduleFixedFeeQuantityUpdates] */ + @MustBeClosed + fun unscheduleFixedFeeQuantityUpdates( + subscriptionId: String, + params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + unscheduleFixedFeeQuantityUpdates( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unscheduleFixedFeeQuantityUpdates] */ + @MustBeClosed fun unscheduleFixedFeeQuantityUpdates( params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams ): HttpResponseFor = @@ -1243,9 +1881,34 @@ interface SubscriptionService { */ @MustBeClosed fun unschedulePendingPlanChanges( - params: SubscriptionUnschedulePendingPlanChangesParams + subscriptionId: String ): HttpResponseFor = - unschedulePendingPlanChanges(params, RequestOptions.none()) + unschedulePendingPlanChanges( + subscriptionId, + SubscriptionUnschedulePendingPlanChangesParams.none(), + ) + + /** @see [unschedulePendingPlanChanges] */ + @MustBeClosed + fun unschedulePendingPlanChanges( + subscriptionId: String, + params: SubscriptionUnschedulePendingPlanChangesParams = + SubscriptionUnschedulePendingPlanChangesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + unschedulePendingPlanChanges( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [unschedulePendingPlanChanges] */ + @MustBeClosed + fun unschedulePendingPlanChanges( + subscriptionId: String, + params: SubscriptionUnschedulePendingPlanChangesParams = + SubscriptionUnschedulePendingPlanChangesParams.none(), + ): HttpResponseFor = + unschedulePendingPlanChanges(subscriptionId, params, RequestOptions.none()) /** @see [unschedulePendingPlanChanges] */ @MustBeClosed @@ -1254,12 +1917,51 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [unschedulePendingPlanChanges] */ + @MustBeClosed + fun unschedulePendingPlanChanges( + params: SubscriptionUnschedulePendingPlanChangesParams + ): HttpResponseFor = + unschedulePendingPlanChanges(params, RequestOptions.none()) + + /** @see [unschedulePendingPlanChanges] */ + @MustBeClosed + fun unschedulePendingPlanChanges( + subscriptionId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + unschedulePendingPlanChanges( + subscriptionId, + SubscriptionUnschedulePendingPlanChangesParams.none(), + requestOptions, + ) + /** * Returns a raw HTTP response for `post * /subscriptions/{subscription_id}/update_fixed_fee_quantity`, but is otherwise the same as * [SubscriptionService.updateFixedFeeQuantity]. */ @MustBeClosed + fun updateFixedFeeQuantity( + subscriptionId: String, + params: SubscriptionUpdateFixedFeeQuantityParams, + ): HttpResponseFor = + updateFixedFeeQuantity(subscriptionId, params, RequestOptions.none()) + + /** @see [updateFixedFeeQuantity] */ + @MustBeClosed + fun updateFixedFeeQuantity( + subscriptionId: String, + params: SubscriptionUpdateFixedFeeQuantityParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + updateFixedFeeQuantity( + params.toBuilder().subscriptionId(subscriptionId).build(), + requestOptions, + ) + + /** @see [updateFixedFeeQuantity] */ + @MustBeClosed fun updateFixedFeeQuantity( params: SubscriptionUpdateFixedFeeQuantityParams ): HttpResponseFor = @@ -1277,6 +1979,23 @@ interface SubscriptionService { * is otherwise the same as [SubscriptionService.updateTrial]. */ @MustBeClosed + fun updateTrial( + subscriptionId: String, + params: SubscriptionUpdateTrialParams, + ): HttpResponseFor = + updateTrial(subscriptionId, params, RequestOptions.none()) + + /** @see [updateTrial] */ + @MustBeClosed + fun updateTrial( + subscriptionId: String, + params: SubscriptionUpdateTrialParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + updateTrial(params.toBuilder().subscriptionId(subscriptionId).build(), requestOptions) + + /** @see [updateTrial] */ + @MustBeClosed fun updateTrial( params: SubscriptionUpdateTrialParams ): HttpResponseFor = diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt index f327e26b..16503774 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/SubscriptionServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -48,6 +49,7 @@ import com.withorb.api.models.SubscriptionUpdateTrialParams import com.withorb.api.models.SubscriptionUpdateTrialResponse import com.withorb.api.models.SubscriptionUsage import com.withorb.api.models.Subscriptions +import kotlin.jvm.optionals.getOrNull class SubscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionService { @@ -210,6 +212,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -271,6 +276,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionCancelParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -298,6 +306,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -325,6 +336,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionFetchCostsParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -352,6 +366,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionFetchScheduleParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -385,6 +402,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionFetchUsageParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -412,6 +432,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionPriceIntervalsParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -440,6 +463,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionSchedulePlanChangeParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -468,6 +494,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionTriggerPhaseParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -497,6 +526,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionUnscheduleCancellationParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -532,6 +564,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionUnscheduleFixedFeeQuantityUpdatesParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -565,6 +600,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionUnschedulePendingPlanChangesParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -598,6 +636,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionUpdateFixedFeeQuantityParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -630,6 +671,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: SubscriptionUpdateTrialParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("subscriptionId", params.subscriptionId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt index 60beb8ac..a387d181 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionService.kt @@ -21,8 +21,22 @@ interface SubscriptionService { * subscription. For a full discussion of the subscription resource, see * [Subscription](/core-concepts#subscription). */ - fun list(params: CouponSubscriptionListParams): CouponSubscriptionListPage = - list(params, RequestOptions.none()) + fun list(couponId: String): CouponSubscriptionListPage = + list(couponId, CouponSubscriptionListParams.none()) + + /** @see [list] */ + fun list( + couponId: String, + params: CouponSubscriptionListParams = CouponSubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CouponSubscriptionListPage = + list(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [list] */ + fun list( + couponId: String, + params: CouponSubscriptionListParams = CouponSubscriptionListParams.none(), + ): CouponSubscriptionListPage = list(couponId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -30,6 +44,14 @@ interface SubscriptionService { requestOptions: RequestOptions = RequestOptions.none(), ): CouponSubscriptionListPage + /** @see [list] */ + fun list(params: CouponSubscriptionListParams): CouponSubscriptionListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(couponId: String, requestOptions: RequestOptions): CouponSubscriptionListPage = + list(couponId, CouponSubscriptionListParams.none(), requestOptions) + /** * A view of [SubscriptionService] that provides access to raw HTTP responses for each method. */ @@ -40,9 +62,25 @@ interface SubscriptionService { * otherwise the same as [SubscriptionService.list]. */ @MustBeClosed + fun list(couponId: String): HttpResponseFor = + list(couponId, CouponSubscriptionListParams.none()) + + /** @see [list] */ + @MustBeClosed fun list( - params: CouponSubscriptionListParams - ): HttpResponseFor = list(params, RequestOptions.none()) + couponId: String, + params: CouponSubscriptionListParams = CouponSubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().couponId(couponId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + couponId: String, + params: CouponSubscriptionListParams = CouponSubscriptionListParams.none(), + ): HttpResponseFor = + list(couponId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -50,5 +88,19 @@ interface SubscriptionService { params: CouponSubscriptionListParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: CouponSubscriptionListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + couponId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(couponId, CouponSubscriptionListParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt index d19b9301..0dea7d0a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.coupons import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -17,6 +18,7 @@ import com.withorb.api.core.prepare import com.withorb.api.models.CouponSubscriptionListPage import com.withorb.api.models.CouponSubscriptionListParams import com.withorb.api.models.Subscriptions +import kotlin.jvm.optionals.getOrNull class SubscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : SubscriptionService { @@ -46,6 +48,9 @@ class SubscriptionServiceImpl internal constructor(private val clientOptions: Cl params: CouponSubscriptionListParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("couponId", params.couponId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt index 58496cd0..5faa1d9e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionService.kt @@ -21,6 +21,20 @@ interface BalanceTransactionService { * Creates an immutable balance transaction that updates the customer's balance and returns back * the newly created transaction. */ + fun create( + customerId: String, + params: CustomerBalanceTransactionCreateParams, + ): CustomerBalanceTransactionCreateResponse = create(customerId, params, RequestOptions.none()) + + /** @see [create] */ + fun create( + customerId: String, + params: CustomerBalanceTransactionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerBalanceTransactionCreateResponse = + create(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [create] */ fun create( params: CustomerBalanceTransactionCreateParams ): CustomerBalanceTransactionCreateResponse = create(params, RequestOptions.none()) @@ -58,8 +72,22 @@ interface BalanceTransactionService { * synced to a separate invoicing provider. If a payment gateway such as Stripe is used, the * balance will be applied to the invoice before forwarding payment to the gateway. */ - fun list(params: CustomerBalanceTransactionListParams): CustomerBalanceTransactionListPage = - list(params, RequestOptions.none()) + fun list(customerId: String): CustomerBalanceTransactionListPage = + list(customerId, CustomerBalanceTransactionListParams.none()) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerBalanceTransactionListParams = CustomerBalanceTransactionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerBalanceTransactionListPage = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerBalanceTransactionListParams = CustomerBalanceTransactionListParams.none(), + ): CustomerBalanceTransactionListPage = list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -67,6 +95,17 @@ interface BalanceTransactionService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerBalanceTransactionListPage + /** @see [list] */ + fun list(params: CustomerBalanceTransactionListParams): CustomerBalanceTransactionListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list( + customerId: String, + requestOptions: RequestOptions, + ): CustomerBalanceTransactionListPage = + list(customerId, CustomerBalanceTransactionListParams.none(), requestOptions) + /** * A view of [BalanceTransactionService] that provides access to raw HTTP responses for each * method. @@ -78,6 +117,23 @@ interface BalanceTransactionService { * is otherwise the same as [BalanceTransactionService.create]. */ @MustBeClosed + fun create( + customerId: String, + params: CustomerBalanceTransactionCreateParams, + ): HttpResponseFor = + create(customerId, params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + customerId: String, + params: CustomerBalanceTransactionCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed fun create( params: CustomerBalanceTransactionCreateParams ): HttpResponseFor = @@ -95,9 +151,27 @@ interface BalanceTransactionService { * is otherwise the same as [BalanceTransactionService.list]. */ @MustBeClosed + fun list(customerId: String): HttpResponseFor = + list(customerId, CustomerBalanceTransactionListParams.none()) + + /** @see [list] */ + @MustBeClosed fun list( - params: CustomerBalanceTransactionListParams - ): HttpResponseFor = list(params, RequestOptions.none()) + customerId: String, + params: CustomerBalanceTransactionListParams = + CustomerBalanceTransactionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerBalanceTransactionListParams = + CustomerBalanceTransactionListParams.none(), + ): HttpResponseFor = + list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -105,5 +179,19 @@ interface BalanceTransactionService { params: CustomerBalanceTransactionListParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [list] */ + @MustBeClosed + fun list( + params: CustomerBalanceTransactionListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(customerId, CustomerBalanceTransactionListParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt index f5b3f888..ecca6166 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.customers import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -20,6 +21,7 @@ import com.withorb.api.models.CustomerBalanceTransactionCreateResponse import com.withorb.api.models.CustomerBalanceTransactionListPage import com.withorb.api.models.CustomerBalanceTransactionListPageResponse import com.withorb.api.models.CustomerBalanceTransactionListParams +import kotlin.jvm.optionals.getOrNull class BalanceTransactionServiceImpl internal constructor(private val clientOptions: ClientOptions) : BalanceTransactionService { @@ -57,6 +59,9 @@ class BalanceTransactionServiceImpl internal constructor(private val clientOptio params: CustomerBalanceTransactionCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -85,6 +90,9 @@ class BalanceTransactionServiceImpl internal constructor(private val clientOptio params: CustomerBalanceTransactionListParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 7a480744..b620e805 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 @@ -127,8 +127,22 @@ interface CostService { * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and * `secondary_grouping_value` available. */ - fun list(params: CustomerCostListParams): CustomerCostListResponse = - list(params, RequestOptions.none()) + fun list(customerId: String): CustomerCostListResponse = + list(customerId, CustomerCostListParams.none()) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCostListParams = CustomerCostListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCostListResponse = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCostListParams = CustomerCostListParams.none(), + ): CustomerCostListResponse = list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -136,6 +150,14 @@ interface CostService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCostListResponse + /** @see [list] */ + fun list(params: CustomerCostListParams): CustomerCostListResponse = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(customerId: String, requestOptions: RequestOptions): CustomerCostListResponse = + list(customerId, CustomerCostListParams.none(), requestOptions) + /** * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated * by applying pricing information to the underlying usage (see the @@ -246,9 +268,26 @@ interface CostService { * `secondary_grouping_key` based on the matrix price definition, for each `grouping_value` and * `secondary_grouping_value` available. */ + fun listByExternalId(externalCustomerId: String): CustomerCostListByExternalIdResponse = + listByExternalId(externalCustomerId, CustomerCostListByExternalIdParams.none()) + + /** @see [listByExternalId] */ fun listByExternalId( - params: CustomerCostListByExternalIdParams - ): CustomerCostListByExternalIdResponse = listByExternalId(params, RequestOptions.none()) + externalCustomerId: String, + params: CustomerCostListByExternalIdParams = CustomerCostListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCostListByExternalIdResponse = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCostListByExternalIdParams = CustomerCostListByExternalIdParams.none(), + ): CustomerCostListByExternalIdResponse = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ fun listByExternalId( @@ -256,6 +295,22 @@ interface CostService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCostListByExternalIdResponse + /** @see [listByExternalId] */ + fun listByExternalId( + params: CustomerCostListByExternalIdParams + ): CustomerCostListByExternalIdResponse = listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CustomerCostListByExternalIdResponse = + listByExternalId( + externalCustomerId, + CustomerCostListByExternalIdParams.none(), + requestOptions, + ) + /** A view of [CostService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -264,8 +319,25 @@ interface CostService { * the same as [CostService.list]. */ @MustBeClosed - fun list(params: CustomerCostListParams): HttpResponseFor = - list(params, RequestOptions.none()) + fun list(customerId: String): HttpResponseFor = + list(customerId, CustomerCostListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCostListParams = CustomerCostListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCostListParams = CustomerCostListParams.none(), + ): HttpResponseFor = + list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -274,6 +346,19 @@ interface CostService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [list] */ + @MustBeClosed + fun list(params: CustomerCostListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(customerId, CustomerCostListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get * /customers/external_customer_id/{external_customer_id}/costs`, but is otherwise the same @@ -281,9 +366,29 @@ interface CostService { */ @MustBeClosed fun listByExternalId( - params: CustomerCostListByExternalIdParams + externalCustomerId: String ): HttpResponseFor = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCostListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCostListByExternalIdParams = CustomerCostListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCostListByExternalIdParams = CustomerCostListByExternalIdParams.none(), + ): HttpResponseFor = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ @MustBeClosed @@ -291,5 +396,24 @@ interface CostService { params: CustomerCostListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + params: CustomerCostListByExternalIdParams + ): HttpResponseFor = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listByExternalId( + externalCustomerId, + CustomerCostListByExternalIdParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt index cdee75f4..45fdbd67 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CostServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.customers import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -18,6 +19,7 @@ import com.withorb.api.models.CustomerCostListByExternalIdParams import com.withorb.api.models.CustomerCostListByExternalIdResponse import com.withorb.api.models.CustomerCostListParams import com.withorb.api.models.CustomerCostListResponse +import kotlin.jvm.optionals.getOrNull class CostServiceImpl internal constructor(private val clientOptions: ClientOptions) : CostService { @@ -54,6 +56,9 @@ class CostServiceImpl internal constructor(private val clientOptions: ClientOpti params: CustomerCostListParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -81,6 +86,9 @@ class CostServiceImpl internal constructor(private val clientOptions: ClientOpti params: CustomerCostListByExternalIdParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt index 9d6638e1..06e23be3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditService.kt @@ -32,8 +32,22 @@ interface CreditService { * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. */ - fun list(params: CustomerCreditListParams): CustomerCreditListPage = - list(params, RequestOptions.none()) + fun list(customerId: String): CustomerCreditListPage = + list(customerId, CustomerCreditListParams.none()) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditListParams = CustomerCreditListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditListPage = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditListParams = CustomerCreditListParams.none(), + ): CustomerCreditListPage = list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -41,6 +55,14 @@ interface CreditService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCreditListPage + /** @see [list] */ + fun list(params: CustomerCreditListParams): CustomerCreditListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(customerId: String, requestOptions: RequestOptions): CustomerCreditListPage = + list(customerId, CustomerCreditListParams.none(), requestOptions) + /** * Returns a paginated list of unexpired, non-zero credit blocks for a customer. * @@ -50,9 +72,26 @@ interface CreditService { * Note that `currency` defaults to credits if not specified. To use a real world currency, set * `currency` to an ISO 4217 string. */ + fun listByExternalId(externalCustomerId: String): CustomerCreditListByExternalIdPage = + listByExternalId(externalCustomerId, CustomerCreditListByExternalIdParams.none()) + + /** @see [listByExternalId] */ fun listByExternalId( - params: CustomerCreditListByExternalIdParams - ): CustomerCreditListByExternalIdPage = listByExternalId(params, RequestOptions.none()) + externalCustomerId: String, + params: CustomerCreditListByExternalIdParams = CustomerCreditListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditListByExternalIdPage = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditListByExternalIdParams = CustomerCreditListByExternalIdParams.none(), + ): CustomerCreditListByExternalIdPage = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ fun listByExternalId( @@ -60,6 +99,22 @@ interface CreditService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCreditListByExternalIdPage + /** @see [listByExternalId] */ + fun listByExternalId( + params: CustomerCreditListByExternalIdParams + ): CustomerCreditListByExternalIdPage = listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CustomerCreditListByExternalIdPage = + listByExternalId( + externalCustomerId, + CustomerCreditListByExternalIdParams.none(), + requestOptions, + ) + /** A view of [CreditService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -72,8 +127,24 @@ interface CreditService { * the same as [CreditService.list]. */ @MustBeClosed - fun list(params: CustomerCreditListParams): HttpResponseFor = - list(params, RequestOptions.none()) + fun list(customerId: String): HttpResponseFor = + list(customerId, CustomerCreditListParams.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditListParams = CustomerCreditListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditListParams = CustomerCreditListParams.none(), + ): HttpResponseFor = list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -82,6 +153,19 @@ interface CreditService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [list] */ + @MustBeClosed + fun list(params: CustomerCreditListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(customerId, CustomerCreditListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get * /customers/external_customer_id/{external_customer_id}/credits`, but is otherwise the @@ -89,9 +173,31 @@ interface CreditService { */ @MustBeClosed fun listByExternalId( - params: CustomerCreditListByExternalIdParams + externalCustomerId: String ): HttpResponseFor = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCreditListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditListByExternalIdParams = + CustomerCreditListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditListByExternalIdParams = + CustomerCreditListByExternalIdParams.none(), + ): HttpResponseFor = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ @MustBeClosed @@ -99,5 +205,24 @@ interface CreditService { params: CustomerCreditListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + params: CustomerCreditListByExternalIdParams + ): HttpResponseFor = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listByExternalId( + externalCustomerId, + CustomerCreditListByExternalIdParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt index 421613a6..30f623f9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/CreditServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.customers import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -24,6 +25,7 @@ import com.withorb.api.services.blocking.customers.credits.LedgerService import com.withorb.api.services.blocking.customers.credits.LedgerServiceImpl import com.withorb.api.services.blocking.customers.credits.TopUpService import com.withorb.api.services.blocking.customers.credits.TopUpServiceImpl +import kotlin.jvm.optionals.getOrNull class CreditServiceImpl internal constructor(private val clientOptions: ClientOptions) : CreditService { @@ -81,6 +83,9 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp params: CustomerCreditListParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -115,6 +120,9 @@ class CreditServiceImpl internal constructor(private val clientOptions: ClientOp params: CustomerCreditListByExternalIdParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 27473ba1..d23b56a7 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 @@ -100,8 +100,22 @@ interface LedgerService { * 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. */ - fun list(params: CustomerCreditLedgerListParams): CustomerCreditLedgerListPage = - list(params, RequestOptions.none()) + fun list(customerId: String): CustomerCreditLedgerListPage = + list(customerId, CustomerCreditLedgerListParams.none()) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditLedgerListParams = CustomerCreditLedgerListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditLedgerListPage = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditLedgerListParams = CustomerCreditLedgerListParams.none(), + ): CustomerCreditLedgerListPage = list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -109,6 +123,14 @@ interface LedgerService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCreditLedgerListPage + /** @see [list] */ + fun list(params: CustomerCreditLedgerListParams): CustomerCreditLedgerListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(customerId: String, requestOptions: RequestOptions): CustomerCreditLedgerListPage = + list(customerId, CustomerCreditLedgerListParams.none(), requestOptions) + /** * This endpoint allows you to create a new ledger entry for a specified customer's balance. * This can be used to increment balance, deduct credits, and change the expiry date of existing @@ -212,6 +234,21 @@ interface LedgerService { * decremented from, and `amount` indicates how many credits to return to the customer, up to * the block's initial balance. */ + fun createEntry( + customerId: String, + params: CustomerCreditLedgerCreateEntryParams, + ): CustomerCreditLedgerCreateEntryResponse = + createEntry(customerId, params, RequestOptions.none()) + + /** @see [createEntry] */ + fun createEntry( + customerId: String, + params: CustomerCreditLedgerCreateEntryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditLedgerCreateEntryResponse = + createEntry(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [createEntry] */ fun createEntry( params: CustomerCreditLedgerCreateEntryParams ): CustomerCreditLedgerCreateEntryResponse = createEntry(params, RequestOptions.none()) @@ -325,6 +362,24 @@ interface LedgerService { * decremented from, and `amount` indicates how many credits to return to the customer, up to * the block's initial balance. */ + fun createEntryByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + ): CustomerCreditLedgerCreateEntryByExternalIdResponse = + createEntryByExternalId(externalCustomerId, params, RequestOptions.none()) + + /** @see [createEntryByExternalId] */ + fun createEntryByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditLedgerCreateEntryByExternalIdResponse = + createEntryByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createEntryByExternalId] */ fun createEntryByExternalId( params: CustomerCreditLedgerCreateEntryByExternalIdParams ): CustomerCreditLedgerCreateEntryByExternalIdResponse = @@ -415,9 +470,28 @@ interface LedgerService { * 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. */ + fun listByExternalId(externalCustomerId: String): CustomerCreditLedgerListByExternalIdPage = + listByExternalId(externalCustomerId, CustomerCreditLedgerListByExternalIdParams.none()) + + /** @see [listByExternalId] */ fun listByExternalId( - params: CustomerCreditLedgerListByExternalIdParams - ): CustomerCreditLedgerListByExternalIdPage = listByExternalId(params, RequestOptions.none()) + externalCustomerId: String, + params: CustomerCreditLedgerListByExternalIdParams = + CustomerCreditLedgerListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditLedgerListByExternalIdPage = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerListByExternalIdParams = + CustomerCreditLedgerListByExternalIdParams.none(), + ): CustomerCreditLedgerListByExternalIdPage = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ fun listByExternalId( @@ -425,6 +499,22 @@ interface LedgerService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCreditLedgerListByExternalIdPage + /** @see [listByExternalId] */ + fun listByExternalId( + params: CustomerCreditLedgerListByExternalIdParams + ): CustomerCreditLedgerListByExternalIdPage = listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CustomerCreditLedgerListByExternalIdPage = + listByExternalId( + externalCustomerId, + CustomerCreditLedgerListByExternalIdParams.none(), + requestOptions, + ) + /** A view of [LedgerService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -433,9 +523,25 @@ interface LedgerService { * otherwise the same as [LedgerService.list]. */ @MustBeClosed + fun list(customerId: String): HttpResponseFor = + list(customerId, CustomerCreditLedgerListParams.none()) + + /** @see [list] */ + @MustBeClosed fun list( - params: CustomerCreditLedgerListParams - ): HttpResponseFor = list(params, RequestOptions.none()) + customerId: String, + params: CustomerCreditLedgerListParams = CustomerCreditLedgerListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditLedgerListParams = CustomerCreditLedgerListParams.none(), + ): HttpResponseFor = + list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -444,11 +550,42 @@ interface LedgerService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [list] */ + @MustBeClosed + fun list( + params: CustomerCreditLedgerListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(customerId, CustomerCreditLedgerListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /customers/{customer_id}/credits/ledger_entry`, but * is otherwise the same as [LedgerService.createEntry]. */ @MustBeClosed + fun createEntry( + customerId: String, + params: CustomerCreditLedgerCreateEntryParams, + ): HttpResponseFor = + createEntry(customerId, params, RequestOptions.none()) + + /** @see [createEntry] */ + @MustBeClosed + fun createEntry( + customerId: String, + params: CustomerCreditLedgerCreateEntryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + createEntry(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [createEntry] */ + @MustBeClosed fun createEntry( params: CustomerCreditLedgerCreateEntryParams ): HttpResponseFor = @@ -467,6 +604,26 @@ interface LedgerService { * otherwise the same as [LedgerService.createEntryByExternalId]. */ @MustBeClosed + fun createEntryByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + ): HttpResponseFor = + createEntryByExternalId(externalCustomerId, params, RequestOptions.none()) + + /** @see [createEntryByExternalId] */ + @MustBeClosed + fun createEntryByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerCreateEntryByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + createEntryByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createEntryByExternalId] */ + @MustBeClosed fun createEntryByExternalId( params: CustomerCreditLedgerCreateEntryByExternalIdParams ): HttpResponseFor = @@ -486,9 +643,31 @@ interface LedgerService { */ @MustBeClosed fun listByExternalId( - params: CustomerCreditLedgerListByExternalIdParams + externalCustomerId: String ): HttpResponseFor = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCreditLedgerListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerListByExternalIdParams = + CustomerCreditLedgerListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditLedgerListByExternalIdParams = + CustomerCreditLedgerListByExternalIdParams.none(), + ): HttpResponseFor = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ @MustBeClosed @@ -496,5 +675,24 @@ interface LedgerService { params: CustomerCreditLedgerListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + params: CustomerCreditLedgerListByExternalIdParams + ): HttpResponseFor = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listByExternalId( + externalCustomerId, + CustomerCreditLedgerListByExternalIdParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt index 25a4c60b..23ffb601 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/LedgerServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.customers.credits import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -25,6 +26,7 @@ import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerListPage import com.withorb.api.models.CustomerCreditLedgerListPageResponse import com.withorb.api.models.CustomerCreditLedgerListParams +import kotlin.jvm.optionals.getOrNull class LedgerServiceImpl internal constructor(private val clientOptions: ClientOptions) : LedgerService { @@ -76,6 +78,9 @@ class LedgerServiceImpl internal constructor(private val clientOptions: ClientOp params: CustomerCreditLedgerListParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -110,6 +115,9 @@ class LedgerServiceImpl internal constructor(private val clientOptions: ClientOp params: CustomerCreditLedgerCreateEntryParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -141,6 +149,9 @@ class LedgerServiceImpl internal constructor(private val clientOptions: ClientOp params: CustomerCreditLedgerCreateEntryByExternalIdParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -176,6 +187,9 @@ class LedgerServiceImpl internal constructor(private val clientOptions: ClientOp params: CustomerCreditLedgerListByExternalIdParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt index 6714d22a..27bee5fa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpService.kt @@ -32,6 +32,20 @@ interface TopUpService { * If a top-up already exists for this customer in the same currency, the existing top-up will * be replaced. */ + fun create( + customerId: String, + params: CustomerCreditTopUpCreateParams, + ): CustomerCreditTopUpCreateResponse = create(customerId, params, RequestOptions.none()) + + /** @see [create] */ + fun create( + customerId: String, + params: CustomerCreditTopUpCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditTopUpCreateResponse = + create(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [create] */ fun create(params: CustomerCreditTopUpCreateParams): CustomerCreditTopUpCreateResponse = create(params, RequestOptions.none()) @@ -42,8 +56,22 @@ interface TopUpService { ): CustomerCreditTopUpCreateResponse /** List top-ups */ - fun list(params: CustomerCreditTopUpListParams): CustomerCreditTopUpListPage = - list(params, RequestOptions.none()) + fun list(customerId: String): CustomerCreditTopUpListPage = + list(customerId, CustomerCreditTopUpListParams.none()) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditTopUpListParams = CustomerCreditTopUpListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditTopUpListPage = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + fun list( + customerId: String, + params: CustomerCreditTopUpListParams = CustomerCreditTopUpListParams.none(), + ): CustomerCreditTopUpListPage = list(customerId, params, RequestOptions.none()) /** @see [list] */ fun list( @@ -51,10 +79,29 @@ interface TopUpService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCreditTopUpListPage + /** @see [list] */ + fun list(params: CustomerCreditTopUpListParams): CustomerCreditTopUpListPage = + list(params, RequestOptions.none()) + + /** @see [list] */ + fun list(customerId: String, requestOptions: RequestOptions): CustomerCreditTopUpListPage = + list(customerId, CustomerCreditTopUpListParams.none(), requestOptions) + /** * This deactivates the top-up and voids any invoices associated with pending credit blocks * purchased through the top-up. */ + fun delete(topUpId: String, params: CustomerCreditTopUpDeleteParams) = + delete(topUpId, params, RequestOptions.none()) + + /** @see [delete] */ + fun delete( + topUpId: String, + params: CustomerCreditTopUpDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().topUpId(topUpId).build(), requestOptions) + + /** @see [delete] */ fun delete(params: CustomerCreditTopUpDeleteParams) = delete(params, RequestOptions.none()) /** @see [delete] */ @@ -71,6 +118,24 @@ interface TopUpService { * If a top-up already exists for this customer in the same currency, the existing top-up will * be replaced. */ + fun createByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpCreateByExternalIdParams, + ): CustomerCreditTopUpCreateByExternalIdResponse = + createByExternalId(externalCustomerId, params, RequestOptions.none()) + + /** @see [createByExternalId] */ + fun createByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpCreateByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditTopUpCreateByExternalIdResponse = + createByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createByExternalId] */ fun createByExternalId( params: CustomerCreditTopUpCreateByExternalIdParams ): CustomerCreditTopUpCreateByExternalIdResponse = @@ -86,6 +151,17 @@ interface TopUpService { * This deactivates the top-up and voids any invoices associated with pending credit blocks * purchased through the top-up. */ + fun deleteByExternalId(topUpId: String, params: CustomerCreditTopUpDeleteByExternalIdParams) = + deleteByExternalId(topUpId, params, RequestOptions.none()) + + /** @see [deleteByExternalId] */ + fun deleteByExternalId( + topUpId: String, + params: CustomerCreditTopUpDeleteByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = deleteByExternalId(params.toBuilder().topUpId(topUpId).build(), requestOptions) + + /** @see [deleteByExternalId] */ fun deleteByExternalId(params: CustomerCreditTopUpDeleteByExternalIdParams) = deleteByExternalId(params, RequestOptions.none()) @@ -96,9 +172,28 @@ interface TopUpService { ) /** List top-ups by external ID */ + fun listByExternalId(externalCustomerId: String): CustomerCreditTopUpListByExternalIdPage = + listByExternalId(externalCustomerId, CustomerCreditTopUpListByExternalIdParams.none()) + + /** @see [listByExternalId] */ fun listByExternalId( - params: CustomerCreditTopUpListByExternalIdParams - ): CustomerCreditTopUpListByExternalIdPage = listByExternalId(params, RequestOptions.none()) + externalCustomerId: String, + params: CustomerCreditTopUpListByExternalIdParams = + CustomerCreditTopUpListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CustomerCreditTopUpListByExternalIdPage = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpListByExternalIdParams = + CustomerCreditTopUpListByExternalIdParams.none(), + ): CustomerCreditTopUpListByExternalIdPage = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ fun listByExternalId( @@ -106,6 +201,22 @@ interface TopUpService { requestOptions: RequestOptions = RequestOptions.none(), ): CustomerCreditTopUpListByExternalIdPage + /** @see [listByExternalId] */ + fun listByExternalId( + params: CustomerCreditTopUpListByExternalIdParams + ): CustomerCreditTopUpListByExternalIdPage = listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): CustomerCreditTopUpListByExternalIdPage = + listByExternalId( + externalCustomerId, + CustomerCreditTopUpListByExternalIdParams.none(), + requestOptions, + ) + /** A view of [TopUpService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -114,6 +225,23 @@ interface TopUpService { * otherwise the same as [TopUpService.create]. */ @MustBeClosed + fun create( + customerId: String, + params: CustomerCreditTopUpCreateParams, + ): HttpResponseFor = + create(customerId, params, RequestOptions.none()) + + /** @see [create] */ + @MustBeClosed + fun create( + customerId: String, + params: CustomerCreditTopUpCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [create] */ + @MustBeClosed fun create( params: CustomerCreditTopUpCreateParams ): HttpResponseFor = @@ -131,9 +259,25 @@ interface TopUpService { * otherwise the same as [TopUpService.list]. */ @MustBeClosed + fun list(customerId: String): HttpResponseFor = + list(customerId, CustomerCreditTopUpListParams.none()) + + /** @see [list] */ + @MustBeClosed fun list( - params: CustomerCreditTopUpListParams - ): HttpResponseFor = list(params, RequestOptions.none()) + customerId: String, + params: CustomerCreditTopUpListParams = CustomerCreditTopUpListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().customerId(customerId).build(), requestOptions) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + params: CustomerCreditTopUpListParams = CustomerCreditTopUpListParams.none(), + ): HttpResponseFor = + list(customerId, params, RequestOptions.none()) /** @see [list] */ @MustBeClosed @@ -142,12 +286,39 @@ interface TopUpService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [list] */ + @MustBeClosed + fun list( + params: CustomerCreditTopUpListParams + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see [list] */ + @MustBeClosed + fun list( + customerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(customerId, CustomerCreditTopUpListParams.none(), requestOptions) + /** * Returns a raw HTTP response for `delete * /customers/{customer_id}/credits/top_ups/{top_up_id}`, but is otherwise the same as * [TopUpService.delete]. */ @MustBeClosed + fun delete(topUpId: String, params: CustomerCreditTopUpDeleteParams): HttpResponse = + delete(topUpId, params, RequestOptions.none()) + + /** @see [delete] */ + @MustBeClosed + fun delete( + topUpId: String, + params: CustomerCreditTopUpDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().topUpId(topUpId).build(), requestOptions) + + /** @see [delete] */ + @MustBeClosed fun delete(params: CustomerCreditTopUpDeleteParams): HttpResponse = delete(params, RequestOptions.none()) @@ -164,6 +335,26 @@ interface TopUpService { * the same as [TopUpService.createByExternalId]. */ @MustBeClosed + fun createByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpCreateByExternalIdParams, + ): HttpResponseFor = + createByExternalId(externalCustomerId, params, RequestOptions.none()) + + /** @see [createByExternalId] */ + @MustBeClosed + fun createByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpCreateByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + createByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [createByExternalId] */ + @MustBeClosed fun createByExternalId( params: CustomerCreditTopUpCreateByExternalIdParams ): HttpResponseFor = @@ -182,6 +373,22 @@ interface TopUpService { * is otherwise the same as [TopUpService.deleteByExternalId]. */ @MustBeClosed + fun deleteByExternalId( + topUpId: String, + params: CustomerCreditTopUpDeleteByExternalIdParams, + ): HttpResponse = deleteByExternalId(topUpId, params, RequestOptions.none()) + + /** @see [deleteByExternalId] */ + @MustBeClosed + fun deleteByExternalId( + topUpId: String, + params: CustomerCreditTopUpDeleteByExternalIdParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = + deleteByExternalId(params.toBuilder().topUpId(topUpId).build(), requestOptions) + + /** @see [deleteByExternalId] */ + @MustBeClosed fun deleteByExternalId(params: CustomerCreditTopUpDeleteByExternalIdParams): HttpResponse = deleteByExternalId(params, RequestOptions.none()) @@ -199,9 +406,31 @@ interface TopUpService { */ @MustBeClosed fun listByExternalId( - params: CustomerCreditTopUpListByExternalIdParams + externalCustomerId: String ): HttpResponseFor = - listByExternalId(params, RequestOptions.none()) + listByExternalId(externalCustomerId, CustomerCreditTopUpListByExternalIdParams.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpListByExternalIdParams = + CustomerCreditTopUpListByExternalIdParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listByExternalId( + params.toBuilder().externalCustomerId(externalCustomerId).build(), + requestOptions, + ) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + params: CustomerCreditTopUpListByExternalIdParams = + CustomerCreditTopUpListByExternalIdParams.none(), + ): HttpResponseFor = + listByExternalId(externalCustomerId, params, RequestOptions.none()) /** @see [listByExternalId] */ @MustBeClosed @@ -209,5 +438,24 @@ interface TopUpService { params: CustomerCreditTopUpListByExternalIdParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + params: CustomerCreditTopUpListByExternalIdParams + ): HttpResponseFor = + listByExternalId(params, RequestOptions.none()) + + /** @see [listByExternalId] */ + @MustBeClosed + fun listByExternalId( + externalCustomerId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listByExternalId( + externalCustomerId, + CustomerCreditTopUpListByExternalIdParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt index 626104a6..39568133 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.customers.credits import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.emptyHandler import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler @@ -29,6 +30,7 @@ import com.withorb.api.models.CustomerCreditTopUpListByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpListPage import com.withorb.api.models.CustomerCreditTopUpListPageResponse import com.withorb.api.models.CustomerCreditTopUpListParams +import kotlin.jvm.optionals.getOrNull class TopUpServiceImpl internal constructor(private val clientOptions: ClientOptions) : TopUpService { @@ -93,6 +95,9 @@ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOpt params: CustomerCreditTopUpCreateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -121,6 +126,9 @@ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOpt params: CustomerCreditTopUpListParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("customerId", params.customerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -153,6 +161,9 @@ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOpt params: CustomerCreditTopUpDeleteParams, requestOptions: RequestOptions, ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topUpId", params.topUpId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -180,6 +191,9 @@ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOpt params: CustomerCreditTopUpCreateByExternalIdParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -213,6 +227,9 @@ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOpt params: CustomerCreditTopUpDeleteByExternalIdParams, requestOptions: RequestOptions, ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topUpId", params.topUpId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -241,6 +258,9 @@ class TopUpServiceImpl internal constructor(private val clientOptions: ClientOpt params: CustomerCreditTopUpListByExternalIdParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalCustomerId", params.externalCustomerId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdService.kt index d1ac55cd..ccc38f0f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdService.kt @@ -16,9 +16,34 @@ interface ExternalDimensionalPriceGroupIdService { fun withRawResponse(): WithRawResponse /** Fetch dimensional price group by external ID */ + fun retrieve(externalDimensionalPriceGroupId: String): DimensionalPriceGroup = + retrieve( + externalDimensionalPriceGroupId, + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + ) + + /** @see [retrieve] */ fun retrieve( - params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams - ): DimensionalPriceGroup = retrieve(params, RequestOptions.none()) + externalDimensionalPriceGroupId: String, + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DimensionalPriceGroup = + retrieve( + params + .toBuilder() + .externalDimensionalPriceGroupId(externalDimensionalPriceGroupId) + .build(), + requestOptions, + ) + + /** @see [retrieve] */ + fun retrieve( + externalDimensionalPriceGroupId: String, + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + ): DimensionalPriceGroup = + retrieve(externalDimensionalPriceGroupId, params, RequestOptions.none()) /** @see [retrieve] */ fun retrieve( @@ -26,6 +51,22 @@ interface ExternalDimensionalPriceGroupIdService { requestOptions: RequestOptions = RequestOptions.none(), ): DimensionalPriceGroup + /** @see [retrieve] */ + fun retrieve( + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams + ): DimensionalPriceGroup = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + fun retrieve( + externalDimensionalPriceGroupId: String, + requestOptions: RequestOptions, + ): DimensionalPriceGroup = + retrieve( + externalDimensionalPriceGroupId, + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + requestOptions, + ) + /** * A view of [ExternalDimensionalPriceGroupIdService] that provides access to raw HTTP responses * for each method. @@ -39,8 +80,37 @@ interface ExternalDimensionalPriceGroupIdService { */ @MustBeClosed fun retrieve( - params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) + externalDimensionalPriceGroupId: String + ): HttpResponseFor = + retrieve( + externalDimensionalPriceGroupId, + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + ) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + externalDimensionalPriceGroupId: String, + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve( + params + .toBuilder() + .externalDimensionalPriceGroupId(externalDimensionalPriceGroupId) + .build(), + requestOptions, + ) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + externalDimensionalPriceGroupId: String, + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams = + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + ): HttpResponseFor = + retrieve(externalDimensionalPriceGroupId, params, RequestOptions.none()) /** @see [retrieve] */ @MustBeClosed @@ -48,5 +118,23 @@ interface ExternalDimensionalPriceGroupIdService { params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see [retrieve] */ + @MustBeClosed + fun retrieve( + externalDimensionalPriceGroupId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve( + externalDimensionalPriceGroupId, + DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.none(), + requestOptions, + ) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceImpl.kt index b22f2e41..ce3cd2e7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.dimensionalPriceGroups import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -16,6 +17,7 @@ import com.withorb.api.core.http.parseable import com.withorb.api.core.prepare import com.withorb.api.models.DimensionalPriceGroup import com.withorb.api.models.DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams +import kotlin.jvm.optionals.getOrNull class ExternalDimensionalPriceGroupIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -49,6 +51,12 @@ internal constructor(private val clientOptions: ClientOptions) : params: DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired( + "externalDimensionalPriceGroupId", + params.externalDimensionalPriceGroupId().getOrNull(), + ) val request = HttpRequest.builder() .method(HttpMethod.GET) 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 37532f16..d5835949 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 @@ -92,8 +92,22 @@ interface BackfillService { * asynchronously reflect the updated usage in invoice amounts and usage graphs. Once all of the * updates are complete, the backfill's status will transition to `reflected`. */ - fun close(params: EventBackfillCloseParams): EventBackfillCloseResponse = - close(params, RequestOptions.none()) + fun close(backfillId: String): EventBackfillCloseResponse = + close(backfillId, EventBackfillCloseParams.none()) + + /** @see [close] */ + fun close( + backfillId: String, + params: EventBackfillCloseParams = EventBackfillCloseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EventBackfillCloseResponse = + close(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [close] */ + fun close( + backfillId: String, + params: EventBackfillCloseParams = EventBackfillCloseParams.none(), + ): EventBackfillCloseResponse = close(backfillId, params, RequestOptions.none()) /** @see [close] */ fun close( @@ -101,9 +115,31 @@ interface BackfillService { requestOptions: RequestOptions = RequestOptions.none(), ): EventBackfillCloseResponse + /** @see [close] */ + fun close(params: EventBackfillCloseParams): EventBackfillCloseResponse = + close(params, RequestOptions.none()) + + /** @see [close] */ + fun close(backfillId: String, requestOptions: RequestOptions): EventBackfillCloseResponse = + close(backfillId, EventBackfillCloseParams.none(), requestOptions) + /** This endpoint is used to fetch a backfill given an identifier. */ - fun fetch(params: EventBackfillFetchParams): EventBackfillFetchResponse = - fetch(params, RequestOptions.none()) + fun fetch(backfillId: String): EventBackfillFetchResponse = + fetch(backfillId, EventBackfillFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + backfillId: String, + params: EventBackfillFetchParams = EventBackfillFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EventBackfillFetchResponse = + fetch(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + backfillId: String, + params: EventBackfillFetchParams = EventBackfillFetchParams.none(), + ): EventBackfillFetchResponse = fetch(backfillId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -111,6 +147,14 @@ interface BackfillService { requestOptions: RequestOptions = RequestOptions.none(), ): EventBackfillFetchResponse + /** @see [fetch] */ + fun fetch(params: EventBackfillFetchParams): EventBackfillFetchResponse = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(backfillId: String, requestOptions: RequestOptions): EventBackfillFetchResponse = + fetch(backfillId, EventBackfillFetchParams.none(), requestOptions) + /** * Reverting a backfill undoes all the effects of closing the backfill. If the backfill is * reflected, the status will transition to `pending_revert` while the effects of the backfill @@ -119,8 +163,22 @@ interface BackfillService { * If a backfill is reverted before its closed, no usage will be updated as a result of the * backfill and it will immediately transition to `reverted`. */ - fun revert(params: EventBackfillRevertParams): EventBackfillRevertResponse = - revert(params, RequestOptions.none()) + fun revert(backfillId: String): EventBackfillRevertResponse = + revert(backfillId, EventBackfillRevertParams.none()) + + /** @see [revert] */ + fun revert( + backfillId: String, + params: EventBackfillRevertParams = EventBackfillRevertParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): EventBackfillRevertResponse = + revert(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [revert] */ + fun revert( + backfillId: String, + params: EventBackfillRevertParams = EventBackfillRevertParams.none(), + ): EventBackfillRevertResponse = revert(backfillId, params, RequestOptions.none()) /** @see [revert] */ fun revert( @@ -128,6 +186,14 @@ interface BackfillService { requestOptions: RequestOptions = RequestOptions.none(), ): EventBackfillRevertResponse + /** @see [revert] */ + fun revert(params: EventBackfillRevertParams): EventBackfillRevertResponse = + revert(params, RequestOptions.none()) + + /** @see [revert] */ + fun revert(backfillId: String, requestOptions: RequestOptions): EventBackfillRevertResponse = + revert(backfillId, EventBackfillRevertParams.none(), requestOptions) + /** A view of [BackfillService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -177,8 +243,25 @@ interface BackfillService { * otherwise the same as [BackfillService.close]. */ @MustBeClosed - fun close(params: EventBackfillCloseParams): HttpResponseFor = - close(params, RequestOptions.none()) + fun close(backfillId: String): HttpResponseFor = + close(backfillId, EventBackfillCloseParams.none()) + + /** @see [close] */ + @MustBeClosed + fun close( + backfillId: String, + params: EventBackfillCloseParams = EventBackfillCloseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + close(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [close] */ + @MustBeClosed + fun close( + backfillId: String, + params: EventBackfillCloseParams = EventBackfillCloseParams.none(), + ): HttpResponseFor = + close(backfillId, params, RequestOptions.none()) /** @see [close] */ @MustBeClosed @@ -187,13 +270,43 @@ interface BackfillService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [close] */ + @MustBeClosed + fun close(params: EventBackfillCloseParams): HttpResponseFor = + close(params, RequestOptions.none()) + + /** @see [close] */ + @MustBeClosed + fun close( + backfillId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + close(backfillId, EventBackfillCloseParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /events/backfills/{backfill_id}`, but is otherwise * the same as [BackfillService.fetch]. */ @MustBeClosed - fun fetch(params: EventBackfillFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(backfillId: String): HttpResponseFor = + fetch(backfillId, EventBackfillFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + backfillId: String, + params: EventBackfillFetchParams = EventBackfillFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + backfillId: String, + params: EventBackfillFetchParams = EventBackfillFetchParams.none(), + ): HttpResponseFor = + fetch(backfillId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -202,14 +315,43 @@ interface BackfillService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: EventBackfillFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + backfillId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + fetch(backfillId, EventBackfillFetchParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /events/backfills/{backfill_id}/revert`, but is * otherwise the same as [BackfillService.revert]. */ @MustBeClosed + fun revert(backfillId: String): HttpResponseFor = + revert(backfillId, EventBackfillRevertParams.none()) + + /** @see [revert] */ + @MustBeClosed fun revert( - params: EventBackfillRevertParams - ): HttpResponseFor = revert(params, RequestOptions.none()) + backfillId: String, + params: EventBackfillRevertParams = EventBackfillRevertParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + revert(params.toBuilder().backfillId(backfillId).build(), requestOptions) + + /** @see [revert] */ + @MustBeClosed + fun revert( + backfillId: String, + params: EventBackfillRevertParams = EventBackfillRevertParams.none(), + ): HttpResponseFor = + revert(backfillId, params, RequestOptions.none()) /** @see [revert] */ @MustBeClosed @@ -217,5 +359,19 @@ interface BackfillService { params: EventBackfillRevertParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [revert] */ + @MustBeClosed + fun revert( + params: EventBackfillRevertParams + ): HttpResponseFor = revert(params, RequestOptions.none()) + + /** @see [revert] */ + @MustBeClosed + fun revert( + backfillId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + revert(backfillId, EventBackfillRevertParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt index 5f2af318..6fbf3336 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/events/BackfillServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.events import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -26,6 +27,7 @@ import com.withorb.api.models.EventBackfillListPageResponse import com.withorb.api.models.EventBackfillListParams import com.withorb.api.models.EventBackfillRevertParams import com.withorb.api.models.EventBackfillRevertResponse +import kotlin.jvm.optionals.getOrNull class BackfillServiceImpl internal constructor(private val clientOptions: ClientOptions) : BackfillService { @@ -146,6 +148,9 @@ class BackfillServiceImpl internal constructor(private val clientOptions: Client params: EventBackfillCloseParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("backfillId", params.backfillId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -174,6 +179,9 @@ class BackfillServiceImpl internal constructor(private val clientOptions: Client params: EventBackfillFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("backfillId", params.backfillId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) @@ -201,6 +209,9 @@ class BackfillServiceImpl internal constructor(private val clientOptions: Client params: EventBackfillRevertParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("backfillId", params.backfillId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.POST) 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 0a64853c..39431961 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 @@ -22,7 +22,22 @@ interface ExternalPlanIdService { * * Other fields on a customer are currently immutable. */ - fun update(params: PlanExternalPlanIdUpdateParams): Plan = update(params, RequestOptions.none()) + fun update(otherExternalPlanId: String): Plan = + update(otherExternalPlanId, PlanExternalPlanIdUpdateParams.none()) + + /** @see [update] */ + fun update( + otherExternalPlanId: String, + params: PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Plan = + update(params.toBuilder().otherExternalPlanId(otherExternalPlanId).build(), requestOptions) + + /** @see [update] */ + fun update( + otherExternalPlanId: String, + params: PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams.none(), + ): Plan = update(otherExternalPlanId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -30,6 +45,13 @@ interface ExternalPlanIdService { requestOptions: RequestOptions = RequestOptions.none(), ): Plan + /** @see [update] */ + fun update(params: PlanExternalPlanIdUpdateParams): Plan = update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(otherExternalPlanId: String, requestOptions: RequestOptions): Plan = + update(otherExternalPlanId, PlanExternalPlanIdUpdateParams.none(), requestOptions) + /** * This endpoint is used to fetch [plan](/core-concepts##plan-and-price) details given an * external_plan_id identifier. It returns information about the prices included in the plan and @@ -47,7 +69,21 @@ interface ExternalPlanIdService { * detailed explanation of price types can be found in the * [Price schema](/core-concepts#plan-and-price). " */ - fun fetch(params: PlanExternalPlanIdFetchParams): Plan = fetch(params, RequestOptions.none()) + fun fetch(externalPlanId: String): Plan = + fetch(externalPlanId, PlanExternalPlanIdFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + externalPlanId: String, + params: PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Plan = fetch(params.toBuilder().externalPlanId(externalPlanId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + externalPlanId: String, + params: PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams.none(), + ): Plan = fetch(externalPlanId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -55,6 +91,13 @@ interface ExternalPlanIdService { requestOptions: RequestOptions = RequestOptions.none(), ): Plan + /** @see [fetch] */ + fun fetch(params: PlanExternalPlanIdFetchParams): Plan = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(externalPlanId: String, requestOptions: RequestOptions): Plan = + fetch(externalPlanId, PlanExternalPlanIdFetchParams.none(), requestOptions) + /** * A view of [ExternalPlanIdService] that provides access to raw HTTP responses for each method. */ @@ -65,8 +108,27 @@ interface ExternalPlanIdService { * otherwise the same as [ExternalPlanIdService.update]. */ @MustBeClosed - fun update(params: PlanExternalPlanIdUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(otherExternalPlanId: String): HttpResponseFor = + update(otherExternalPlanId, PlanExternalPlanIdUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + otherExternalPlanId: String, + params: PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update( + params.toBuilder().otherExternalPlanId(otherExternalPlanId).build(), + requestOptions, + ) + + /** @see [update] */ + @MustBeClosed + fun update( + otherExternalPlanId: String, + params: PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams.none(), + ): HttpResponseFor = update(otherExternalPlanId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -75,13 +137,42 @@ interface ExternalPlanIdService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: PlanExternalPlanIdUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + otherExternalPlanId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(otherExternalPlanId, PlanExternalPlanIdUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /plans/external_plan_id/{external_plan_id}`, but is * otherwise the same as [ExternalPlanIdService.fetch]. */ @MustBeClosed - fun fetch(params: PlanExternalPlanIdFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(externalPlanId: String): HttpResponseFor = + fetch(externalPlanId, PlanExternalPlanIdFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + externalPlanId: String, + params: PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().externalPlanId(externalPlanId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + externalPlanId: String, + params: PlanExternalPlanIdFetchParams = PlanExternalPlanIdFetchParams.none(), + ): HttpResponseFor = fetch(externalPlanId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -89,5 +180,15 @@ interface ExternalPlanIdService { params: PlanExternalPlanIdFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: PlanExternalPlanIdFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch(externalPlanId: String, requestOptions: RequestOptions): HttpResponseFor = + fetch(externalPlanId, PlanExternalPlanIdFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt index 464cadc3..6fccf86e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.plans import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -18,6 +19,7 @@ import com.withorb.api.core.prepare import com.withorb.api.models.Plan import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams +import kotlin.jvm.optionals.getOrNull class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPlanIdService { @@ -54,6 +56,9 @@ class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: params: PlanExternalPlanIdUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("otherExternalPlanId", params.otherExternalPlanId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -81,6 +86,9 @@ class ExternalPlanIdServiceImpl internal constructor(private val clientOptions: params: PlanExternalPlanIdFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalPlanId", params.externalPlanId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt index 24353ff8..4ea638ff 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdService.kt @@ -20,8 +20,21 @@ interface ExternalPriceIdService { * This endpoint allows you to update the `metadata` property on a price. If you pass null for * the metadata value, it will clear any existing metadata for that price. */ - fun update(params: PriceExternalPriceIdUpdateParams): Price = - update(params, RequestOptions.none()) + fun update(externalPriceId: String): Price = + update(externalPriceId, PriceExternalPriceIdUpdateParams.none()) + + /** @see [update] */ + fun update( + externalPriceId: String, + params: PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = update(params.toBuilder().externalPriceId(externalPriceId).build(), requestOptions) + + /** @see [update] */ + fun update( + externalPriceId: String, + params: PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams.none(), + ): Price = update(externalPriceId, params, RequestOptions.none()) /** @see [update] */ fun update( @@ -29,12 +42,34 @@ interface ExternalPriceIdService { requestOptions: RequestOptions = RequestOptions.none(), ): Price + /** @see [update] */ + fun update(params: PriceExternalPriceIdUpdateParams): Price = + update(params, RequestOptions.none()) + + /** @see [update] */ + fun update(externalPriceId: String, requestOptions: RequestOptions): Price = + update(externalPriceId, PriceExternalPriceIdUpdateParams.none(), requestOptions) + /** * This endpoint returns a price given an external price id. See the * [price creation API](/api-reference/price/create-price) for more information about external * price aliases. */ - fun fetch(params: PriceExternalPriceIdFetchParams): Price = fetch(params, RequestOptions.none()) + fun fetch(externalPriceId: String): Price = + fetch(externalPriceId, PriceExternalPriceIdFetchParams.none()) + + /** @see [fetch] */ + fun fetch( + externalPriceId: String, + params: PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Price = fetch(params.toBuilder().externalPriceId(externalPriceId).build(), requestOptions) + + /** @see [fetch] */ + fun fetch( + externalPriceId: String, + params: PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams.none(), + ): Price = fetch(externalPriceId, params, RequestOptions.none()) /** @see [fetch] */ fun fetch( @@ -42,6 +77,13 @@ interface ExternalPriceIdService { requestOptions: RequestOptions = RequestOptions.none(), ): Price + /** @see [fetch] */ + fun fetch(params: PriceExternalPriceIdFetchParams): Price = fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + fun fetch(externalPriceId: String, requestOptions: RequestOptions): Price = + fetch(externalPriceId, PriceExternalPriceIdFetchParams.none(), requestOptions) + /** * A view of [ExternalPriceIdService] that provides access to raw HTTP responses for each * method. @@ -53,8 +95,24 @@ interface ExternalPriceIdService { * is otherwise the same as [ExternalPriceIdService.update]. */ @MustBeClosed - fun update(params: PriceExternalPriceIdUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(externalPriceId: String): HttpResponseFor = + update(externalPriceId, PriceExternalPriceIdUpdateParams.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + externalPriceId: String, + params: PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().externalPriceId(externalPriceId).build(), requestOptions) + + /** @see [update] */ + @MustBeClosed + fun update( + externalPriceId: String, + params: PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams.none(), + ): HttpResponseFor = update(externalPriceId, params, RequestOptions.none()) /** @see [update] */ @MustBeClosed @@ -63,13 +121,42 @@ interface ExternalPriceIdService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** @see [update] */ + @MustBeClosed + fun update(params: PriceExternalPriceIdUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see [update] */ + @MustBeClosed + fun update( + externalPriceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(externalPriceId, PriceExternalPriceIdUpdateParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /prices/external_price_id/{external_price_id}`, but * is otherwise the same as [ExternalPriceIdService.fetch]. */ @MustBeClosed - fun fetch(params: PriceExternalPriceIdFetchParams): HttpResponseFor = - fetch(params, RequestOptions.none()) + fun fetch(externalPriceId: String): HttpResponseFor = + fetch(externalPriceId, PriceExternalPriceIdFetchParams.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + externalPriceId: String, + params: PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + fetch(params.toBuilder().externalPriceId(externalPriceId).build(), requestOptions) + + /** @see [fetch] */ + @MustBeClosed + fun fetch( + externalPriceId: String, + params: PriceExternalPriceIdFetchParams = PriceExternalPriceIdFetchParams.none(), + ): HttpResponseFor = fetch(externalPriceId, params, RequestOptions.none()) /** @see [fetch] */ @MustBeClosed @@ -77,5 +164,15 @@ interface ExternalPriceIdService { params: PriceExternalPriceIdFetchParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + + /** @see [fetch] */ + @MustBeClosed + fun fetch(params: PriceExternalPriceIdFetchParams): HttpResponseFor = + fetch(params, RequestOptions.none()) + + /** @see [fetch] */ + @MustBeClosed + fun fetch(externalPriceId: String, requestOptions: RequestOptions): HttpResponseFor = + fetch(externalPriceId, PriceExternalPriceIdFetchParams.none(), requestOptions) } } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt index 8b773019..b0c9db98 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceImpl.kt @@ -5,6 +5,7 @@ package com.withorb.api.services.blocking.prices import com.withorb.api.core.ClientOptions import com.withorb.api.core.JsonValue import com.withorb.api.core.RequestOptions +import com.withorb.api.core.checkRequired import com.withorb.api.core.handlers.errorHandler import com.withorb.api.core.handlers.jsonHandler import com.withorb.api.core.handlers.withErrorHandler @@ -18,6 +19,7 @@ import com.withorb.api.core.prepare import com.withorb.api.models.Price import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams +import kotlin.jvm.optionals.getOrNull class ExternalPriceIdServiceImpl internal constructor(private val clientOptions: ClientOptions) : ExternalPriceIdService { @@ -54,6 +56,9 @@ class ExternalPriceIdServiceImpl internal constructor(private val clientOptions: params: PriceExternalPriceIdUpdateParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalPriceId", params.externalPriceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.PUT) @@ -81,6 +86,9 @@ class ExternalPriceIdServiceImpl internal constructor(private val clientOptions: params: PriceExternalPriceIdFetchParams, requestOptions: RequestOptions, ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("externalPriceId", params.externalPriceId().getOrNull()) val request = HttpRequest.builder() .method(HttpMethod.GET) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/AutoPagerAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/AutoPagerAsyncTest.kt new file mode 100644 index 00000000..625a47af --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/AutoPagerAsyncTest.kt @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core + +import com.withorb.api.core.http.AsyncStreamResponse +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.any +import org.mockito.kotlin.clearInvocations +import org.mockito.kotlin.doAnswer +import org.mockito.kotlin.inOrder +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.spy +import org.mockito.kotlin.times +import org.mockito.kotlin.verify +import org.mockito.kotlin.whenever + +@ExtendWith(MockitoExtension::class) +internal class AutoPagerAsyncTest { + + companion object { + + private val ERROR = RuntimeException("ERROR!") + } + + private class PageAsyncImpl( + private val items: List, + private val hasNext: Boolean = true, + ) : PageAsync { + + val nextPageFuture: CompletableFuture> = CompletableFuture() + + override fun hasNextPage(): Boolean = hasNext + + override fun nextPage(): CompletableFuture> = nextPageFuture + + override fun items(): List = items + } + + private val executor = + spy { + doAnswer { invocation -> invocation.getArgument(0).run() } + .whenever(it) + .execute(any()) + } + private val handler = mock>() + + @Test + fun subscribe_whenAlreadySubscribed_throws() { + val autoPagerAsync = AutoPagerAsync.from(PageAsyncImpl(emptyList()), executor) + autoPagerAsync.subscribe {} + clearInvocations(executor) + + val throwable = catchThrowable { autoPagerAsync.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe more than once") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenClosed_throws() { + val autoPagerAsync = AutoPagerAsync.from(PageAsyncImpl(emptyList()), executor) + autoPagerAsync.close() + + val throwable = catchThrowable { autoPagerAsync.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe after the response is closed") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenFirstPageNonEmpty_runsHandler() { + val page = PageAsyncImpl(listOf("item1", "item2", "item3"), hasNext = false) + val autoPagerAsync = AutoPagerAsync.from(page, executor) + + autoPagerAsync.subscribe(handler) + + inOrder(executor, handler) { + verify(executor, times(1)).execute(any()) + verify(handler, times(1)).onNext("item1") + verify(handler, times(1)).onNext("item2") + verify(handler, times(1)).onNext("item3") + verify(handler, times(1)).onComplete(Optional.empty()) + } + } + + @Test + fun subscribe_whenFutureCompletesAfterClose_doesNothing() { + val page = PageAsyncImpl(listOf("page1")) + val autoPagerAsync = AutoPagerAsync.from(page, executor) + autoPagerAsync.subscribe(handler) + autoPagerAsync.close() + + page.nextPageFuture.complete(PageAsyncImpl(listOf("page2"))) + + verify(handler, times(1)).onNext("page1") + verify(handler, never()).onNext("page2") + verify(handler, times(1)).onComplete(Optional.empty()) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureErrors_callsOnComplete() { + val page = PageAsyncImpl(emptyList()) + val autoPagerAsync = AutoPagerAsync.from(page, executor) + autoPagerAsync.subscribe(handler) + + page.nextPageFuture.completeExceptionally(ERROR) + + verify(executor, times(1)).execute(any()) + verify(handler, never()).onNext(any()) + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + } + + @Test + fun subscribe_whenFutureCompletes_runsHandler() { + val page = PageAsyncImpl(listOf("chunk1", "chunk2")) + val autoPagerAsync = AutoPagerAsync.from(page, executor) + + autoPagerAsync.subscribe(handler) + + verify(handler, never()).onComplete(any()) + inOrder(executor, handler) { + verify(executor, times(1)).execute(any()) + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + } + clearInvocations(executor, handler) + + page.nextPageFuture.complete(PageAsyncImpl(listOf("chunk3", "chunk4"), hasNext = false)) + + verify(executor, never()).execute(any()) + inOrder(handler) { + verify(handler, times(1)).onNext("chunk3") + verify(handler, times(1)).onNext("chunk4") + verify(handler, times(1)).onComplete(Optional.empty()) + } + } + + @Test + fun onCompleteFuture_whenNextPageFutureNotCompleted_onCompleteFutureNotCompleted() { + val page = PageAsyncImpl(listOf("chunk1", "chunk2")) + val autoPagerAsync = AutoPagerAsync.from(page, executor) + autoPagerAsync.subscribe {} + + val onCompletableFuture = autoPagerAsync.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenNextPageFutureErrors_onCompleteFutureCompletedExceptionally() { + val page = PageAsyncImpl(listOf("chunk1", "chunk2")) + val autoPagerAsync = AutoPagerAsync.from(page, executor) + autoPagerAsync.subscribe {} + page.nextPageFuture.completeExceptionally(ERROR) + + val onCompletableFuture = autoPagerAsync.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenNoNextPage_onCompleteFutureCompleted() { + val page = PageAsyncImpl(listOf("chunk1", "chunk2"), hasNext = false) + val autoPagerAsync = AutoPagerAsync.from(page, executor) + autoPagerAsync.subscribe {} + + val onCompletableFuture = autoPagerAsync.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/AutoPagerTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/AutoPagerTest.kt new file mode 100644 index 00000000..1ba0c006 --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/AutoPagerTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.withorb.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AutoPagerTest { + + private class PageImpl( + private val items: List, + private val nextPage: Page? = null, + ) : Page { + + override fun hasNextPage(): Boolean = nextPage != null + + override fun nextPage(): Page = nextPage!! + + override fun items(): List = items + } + + @Test + fun iterator() { + val firstPage = + PageImpl(listOf("chunk1", "chunk2"), nextPage = PageImpl(listOf("chunk3", "chunk4"))) + + val autoPager = AutoPager.from(firstPage) + + assertThat(autoPager).containsExactly("chunk1", "chunk2", "chunk3", "chunk4") + } + + @Test + fun stream() { + val firstPage = + PageImpl(listOf("chunk1", "chunk2"), nextPage = PageImpl(listOf("chunk3", "chunk4"))) + + val autoPager = AutoPager.from(firstPage) + + assertThat(autoPager.stream()).containsExactly("chunk1", "chunk2", "chunk3", "chunk4") + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/PhantomReachableTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/PhantomReachableTest.kt index 0398347e..ff7f5f62 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/PhantomReachableTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/PhantomReachableTest.kt @@ -20,7 +20,7 @@ internal class PhantomReachableTest { assertThat(closed).isFalse() System.gc() - Thread.sleep(3000) + Thread.sleep(100) assertThat(closed).isTrue() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/AsyncStreamResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/AsyncStreamResponseTest.kt new file mode 100644 index 00000000..3fc59d9d --- /dev/null +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/AsyncStreamResponseTest.kt @@ -0,0 +1,268 @@ +package com.withorb.api.core.http + +import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.stream.Stream +import kotlin.streams.asStream +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.* + +@ExtendWith(MockitoExtension::class) +internal class AsyncStreamResponseTest { + + companion object { + private val ERROR = RuntimeException("ERROR!") + } + + private val streamResponse = + spy> { + doReturn(Stream.of("chunk1", "chunk2", "chunk3")).whenever(it).stream() + } + private val erroringStreamResponse = + spy> { + doReturn( + sequence { + yield("chunk1") + yield("chunk2") + throw ERROR + } + .asStream() + ) + .whenever(it) + .stream() + } + private val executor = + spy { + doAnswer { invocation -> invocation.getArgument(0).run() } + .whenever(it) + .execute(any()) + } + private val handler = mock>() + + @Test + fun subscribe_whenAlreadySubscribed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.subscribe {} + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe more than once") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenClosed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.close() + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe after the response is closed") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletesAfterClose_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + asyncStreamResponse.close() + + future.complete(streamResponse) + + verify(handler, never()).onNext(any()) + verify(handler, never()).onComplete(any()) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureErrors_callsOnComplete() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.completeExceptionally(ERROR) + + verify(handler, never()).onNext(any()) + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletes_runsHandler() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(streamResponse) + + inOrder(handler, streamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onNext("chunk3") + verify(handler, times(1)).onComplete(Optional.empty()) + verify(streamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenStreamErrors_callsOnCompleteEarly() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(erroringStreamResponse) + + inOrder(handler, erroringStreamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(erroringStreamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureNotCompleted_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.completeExceptionally(ERROR) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedButStillStreaming_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamCompleted_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithoutThrowableThrows_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithThrowableThrows_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenClosed_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun close_whenNotClosed_closesStreamResponse() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + asyncStreamResponse.close() + future.complete(streamResponse) + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenAlreadyClosed_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + future.complete(streamResponse) + + asyncStreamResponse.close() + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenFutureErrors_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + assertDoesNotThrow { future.completeExceptionally(ERROR) } + } +} diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HeadersTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HeadersTest.kt index ef06e6ce..6ad15e18 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HeadersTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/HeadersTest.kt @@ -1,8 +1,6 @@ package com.withorb.api.core.http import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -241,34 +239,4 @@ internal class HeadersTest { assertThat(size).isEqualTo(testCase.expectedSize) } - - @ParameterizedTest - @EnumSource - fun namesAreImmutable(testCase: TestCase) { - val headers = testCase.headers - val headerNamesCopy = headers.names().toSet() - - val throwable = catchThrowable { - (headers.names() as MutableSet).add("another name") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(headers.names()).isEqualTo(headerNamesCopy) - } - - @ParameterizedTest - @EnumSource - fun valuesAreImmutable(testCase: TestCase) { - val headers = testCase.headers - assumeThat(headers.size).isNotEqualTo(0) - val name = headers.names().first() - val headerValuesCopy = headers.values(name).toList() - - val throwable = catchThrowable { - (headers.values(name) as MutableList).add("another value") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(headers.values(name)).isEqualTo(headerValuesCopy) - } } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/QueryParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/QueryParamsTest.kt index 11c28d37..c9003c20 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/core/http/QueryParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/core/http/QueryParamsTest.kt @@ -1,8 +1,6 @@ package com.withorb.api.core.http import org.assertj.core.api.Assertions.assertThat -import org.assertj.core.api.Assertions.catchThrowable -import org.assertj.core.api.Assumptions.assumeThat import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource @@ -179,34 +177,4 @@ internal class QueryParamsTest { assertThat(size).isEqualTo(testCase.expectedSize) } - - @ParameterizedTest - @EnumSource - fun keysAreImmutable(testCase: TestCase) { - val queryParams = testCase.queryParams - val queryParamKeysCopy = queryParams.keys().toSet() - - val throwable = catchThrowable { - (queryParams.keys() as MutableSet).add("another key") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(queryParams.keys()).isEqualTo(queryParamKeysCopy) - } - - @ParameterizedTest - @EnumSource - fun valuesAreImmutable(testCase: TestCase) { - val queryParams = testCase.queryParams - assumeThat(queryParams.size).isNotEqualTo(0) - val key = queryParams.keys().first() - val queryParamValuesCopy = queryParams.values(key).toList() - - val throwable = catchThrowable { - (queryParams.values(key) as MutableList).add("another value") - } - - assertThat(throwable).isInstanceOf(UnsupportedOperationException::class.java) - assertThat(queryParams.values(key)).isEqualTo(queryParamValuesCopy) - } } 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 2311043c..1a348919 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 @@ -7,13 +7,16 @@ import com.github.tomakehurst.wiremock.stubbing.Scenario import com.withorb.api.client.okhttp.OkHttpClient import com.withorb.api.core.RequestOptions import java.io.InputStream +import java.time.Duration import java.util.concurrent.CompletableFuture import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.parallel.ResourceLock import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.ValueSource @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") internal class RetryingHttpClientTest { private var openResponseCount = 0 @@ -24,6 +27,7 @@ internal class RetryingHttpClientTest { val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() httpClient = object : HttpClient { + override fun execute( request: HttpRequest, requestOptions: RequestOptions, @@ -40,6 +44,7 @@ internal class RetryingHttpClientTest { private fun trackClose(response: HttpResponse): HttpResponse { openResponseCount++ return object : HttpResponse { + private var isClosed = false override fun statusCode(): Int = response.statusCode() @@ -66,7 +71,7 @@ internal class RetryingHttpClientTest { @ValueSource(booleans = [false, true]) fun execute(async: Boolean) { stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) - val retryingClient = RetryingHttpClient.builder().httpClient(httpClient).build() + val retryingClient = retryingHttpClientBuilder().build() val response = retryingClient.execute( @@ -88,11 +93,7 @@ internal class RetryingHttpClientTest { .willReturn(ok()) ) val retryingClient = - RetryingHttpClient.builder() - .httpClient(httpClient) - .maxRetries(2) - .idempotencyHeader("X-Some-Header") - .build() + retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() val response = retryingClient.execute( @@ -134,8 +135,7 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() val response = retryingClient.execute( @@ -181,8 +181,7 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(2).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() val response = retryingClient.execute( @@ -220,8 +219,7 @@ internal class RetryingHttpClientTest { .willReturn(ok()) .willSetStateTo("COMPLETED") ) - val retryingClient = - RetryingHttpClient.builder().httpClient(httpClient).maxRetries(1).build() + val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() val response = retryingClient.execute( @@ -234,6 +232,20 @@ internal class RetryingHttpClientTest { assertNoResponseLeaks() } + private fun retryingHttpClientBuilder() = + RetryingHttpClient.builder() + .httpClient(httpClient) + // Use a no-op `Sleeper` to make the test fast. + .sleeper( + object : RetryingHttpClient.Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + } + ) + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = if (async) executeAsync(request).get() else execute(request) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponCreateParamsTest.kt index 67a6283e..094ddca4 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/CouponCreateParamsTest.kt @@ -10,7 +10,7 @@ internal class CouponCreateParamsTest { @Test fun create() { CouponCreateParams.builder() - .newCouponPercentageDiscount(0.0) + .percentageDiscount(0.0) .redemptionCode("HALFOFF") .durationInMonths(12L) .maxRedemptions(1L) @@ -21,7 +21,7 @@ internal class CouponCreateParamsTest { fun body() { val params = CouponCreateParams.builder() - .newCouponPercentageDiscount(0.0) + .percentageDiscount(0.0) .redemptionCode("HALFOFF") .durationInMonths(12L) .maxRedemptions(1L) @@ -31,14 +31,8 @@ internal class CouponCreateParamsTest { assertThat(body.discount()) .isEqualTo( - CouponCreateParams.Discount.ofNewCouponPercentage( - CouponCreateParams.Discount.NewCouponPercentageDiscount.builder() - .discountType( - CouponCreateParams.Discount.NewCouponPercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.0) - .build() + CouponCreateParams.Discount.ofPercentage( + CouponCreateParams.Discount.Percentage.builder().percentageDiscount(0.0).build() ) ) assertThat(body.redemptionCode()).isEqualTo("HALFOFF") @@ -49,23 +43,14 @@ internal class CouponCreateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = - CouponCreateParams.builder() - .newCouponPercentageDiscount(0.0) - .redemptionCode("HALFOFF") - .build() + CouponCreateParams.builder().percentageDiscount(0.0).redemptionCode("HALFOFF").build() val body = params._body() assertThat(body.discount()) .isEqualTo( - CouponCreateParams.Discount.ofNewCouponPercentage( - CouponCreateParams.Discount.NewCouponPercentageDiscount.builder() - .discountType( - CouponCreateParams.Discount.NewCouponPercentageDiscount.DiscountType - .PERCENTAGE - ) - .percentageDiscount(0.0) - .build() + CouponCreateParams.Discount.ofPercentage( + CouponCreateParams.Discount.Percentage.builder().percentageDiscount(0.0).build() ) ) assertThat(body.redemptionCode()).isEqualTo("HALFOFF") 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 66de2ed2..46c4202e 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 @@ -20,28 +20,26 @@ internal class CustomerCostListByExternalIdResponseTest { .addPerPriceCost( CustomerCostListByExternalIdResponse.Data.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -61,30 +59,27 @@ internal class CustomerCostListByExternalIdResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -92,23 +87,22 @@ internal class CustomerCostListByExternalIdResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -137,26 +131,25 @@ internal class CustomerCostListByExternalIdResponseTest { .addPerPriceCost( CustomerCostListByExternalIdResponse.Data.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -176,48 +169,44 @@ internal class CustomerCostListByExternalIdResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -248,28 +237,26 @@ internal class CustomerCostListByExternalIdResponseTest { .addPerPriceCost( CustomerCostListByExternalIdResponse.Data.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -289,30 +276,27 @@ internal class CustomerCostListByExternalIdResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -320,23 +304,22 @@ internal class CustomerCostListByExternalIdResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" 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 df09c01f..764e48e3 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 @@ -20,28 +20,26 @@ internal class CustomerCostListResponseTest { .addPerPriceCost( CustomerCostListResponse.Data.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -61,30 +59,27 @@ internal class CustomerCostListResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -92,23 +87,22 @@ internal class CustomerCostListResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -137,26 +131,25 @@ internal class CustomerCostListResponseTest { .addPerPriceCost( CustomerCostListResponse.Data.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -176,48 +169,44 @@ internal class CustomerCostListResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -248,28 +237,26 @@ internal class CustomerCostListResponseTest { .addPerPriceCost( CustomerCostListResponse.Data.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -289,30 +276,27 @@ internal class CustomerCostListResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -320,23 +304,22 @@ internal class CustomerCostListResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" 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 c6886211..f1bef4be 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 @@ -68,12 +68,8 @@ internal class CustomerCreateParamsTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -148,13 +144,8 @@ internal class CustomerCreateParamsTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -231,14 +222,9 @@ internal class CustomerCreateParamsTest { ) assertThat(body.taxConfiguration()) .contains( - CustomerCreateParams.TaxConfiguration.ofNewAvalara( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerCreateParams.TaxConfiguration.ofAvalara( + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) 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 2d97e824..547cfd51 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 @@ -14,23 +14,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") .body( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.builder() .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) .currency("currency") .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .InvoiceSettings .builder() .autoCollection(true) @@ -40,9 +31,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .Metadata + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -58,7 +47,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { val params = CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .addIncrementCreditLedgerEntryRequestParamsBody(0.0) + .incrementBody(0.0) .build() assertThat(params._pathParam(0)).isEqualTo("external_customer_id") @@ -72,23 +61,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") .body( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.builder() .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) .currency("currency") .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .InvoiceSettings .builder() .autoCollection(true) @@ -98,8 +78,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -114,44 +93,33 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { assertThat(body) .isEqualTo( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .ofAddIncrementCreditLedgerEntryRequestParams( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() - .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .currency("currency") - .description("description") - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .InvoiceSettings - .builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .Metadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .perUnitCostBasis("per_unit_cost_basis") - .build() - ) + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.ofIncrement( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.builder() + .amount(0.0) + .currency("currency") + .description("description") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoiceSettings( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .InvoiceSettings + .builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .metadata( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment + .Metadata + .builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) ) } @@ -160,27 +128,18 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdParamsTest { val params = CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") - .addIncrementCreditLedgerEntryRequestParamsBody(0.0) + .incrementBody(0.0) .build() val body = params._body() assertThat(body) .isEqualTo( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .ofAddIncrementCreditLedgerEntryRequestParams( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() - .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .build() - ) + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.ofIncrement( + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.builder() + .amount(0.0) + .build() + ) ) } } 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 998e5f28..88eb36d0 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 @@ -16,15 +16,14 @@ import org.junit.jupiter.params.provider.EnumSource internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { @Test - fun ofIncrementLedgerEntry() { - val incrementLedgerEntry = - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry.builder() + fun ofIncrement() { + val increment = + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -33,9 +32,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .Customer - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -43,20 +40,12 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .EntryType - .INCREMENT - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .Metadata - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -64,41 +53,29 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofIncrementLedgerEntry( - incrementLedgerEntry - ) - - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.incrementLedgerEntry()) - .contains(incrementLedgerEntry) - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrementLedgerEntry()) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.expirationChangeLedgerEntry() - ) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiryLedgerEntry() - ) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiatedLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendmentLedgerEntry()) - .isEmpty + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofIncrement(increment) + + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.increment()) + .contains(increment) + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendment()).isEmpty } @Test - fun ofIncrementLedgerEntryRoundtrip() { + fun ofIncrementRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofIncrementLedgerEntry( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofIncrement( + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -107,8 +84,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .Customer + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -117,19 +93,12 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .EntryType - .INCREMENT - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.IncrementLedgerEntry - .Metadata + CustomerCreditLedgerCreateEntryByExternalIdResponse.Increment.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -149,15 +118,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { } @Test - fun ofDecrementLedgerEntry() { - val decrementLedgerEntry = - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry.builder() + fun ofDecrement() { + val decrement = + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -166,9 +134,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .Customer - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -176,20 +142,12 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .EntryType - .DECREMENT - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .Metadata - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -200,41 +158,29 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofDecrementLedgerEntry( - decrementLedgerEntry - ) - - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.incrementLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrementLedgerEntry()) - .contains(decrementLedgerEntry) - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.expirationChangeLedgerEntry() - ) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiryLedgerEntry() - ) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiatedLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendmentLedgerEntry()) - .isEmpty + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofDecrement(decrement) + + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrement()) + .contains(decrement) + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendment()).isEmpty } @Test - fun ofDecrementLedgerEntryRoundtrip() { + fun ofDecrementRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofDecrementLedgerEntry( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry.builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofDecrement( + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -243,8 +189,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .Customer + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -253,19 +198,12 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .EntryType - .DECREMENT - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.DecrementLedgerEntry - .Metadata + CustomerCreditLedgerCreateEntryByExternalIdResponse.Decrement.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -288,16 +226,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { } @Test - fun ofExpirationChangeLedgerEntry() { - val expirationChangeLedgerEntry = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChangeLedgerEntry - .builder() + fun ofExpirationChange() { + val expirationChange = + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChangeLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -306,8 +242,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChangeLedgerEntry - .Customer + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -316,19 +251,12 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChangeLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChangeLedgerEntry - .EntryType - .EXPIRATION_CHANGE - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChangeLedgerEntry - .Metadata + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -338,42 +266,29 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry - ) - - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.incrementLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrementLedgerEntry()) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.expirationChangeLedgerEntry() - ) - .contains(expirationChangeLedgerEntry) - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiryLedgerEntry() - ) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiatedLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendmentLedgerEntry()) - .isEmpty + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofExpirationChange(expirationChange) + + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.expirationChange()) + .contains(expirationChange) + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendment()).isEmpty } @Test - fun ofExpirationChangeLedgerEntryRoundtrip() { + fun ofExpirationChangeRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofExpirationChangeLedgerEntry( - CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChangeLedgerEntry - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofExpirationChange( + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .ExpirationChangeLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange .CreditBlock .builder() .id("id") @@ -383,8 +298,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .ExpirationChangeLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange .Customer .builder() .id("id") @@ -394,21 +308,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .ExpirationChangeLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange .EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .ExpirationChangeLedgerEntry - .EntryType - .EXPIRATION_CHANGE - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .ExpirationChangeLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.ExpirationChange .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -430,15 +336,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { } @Test - fun ofCreditBlockExpiryLedgerEntry() { - val creditBlockExpiryLedgerEntry = - CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiryLedgerEntry - .builder() + fun ofCreditBlockExpiry() { + val creditBlockExpiry = + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiryLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry .CreditBlock .builder() .id("id") @@ -448,8 +353,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiryLedgerEntry - .Customer + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -458,19 +362,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiryLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry .EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiryLedgerEntry - .EntryType - .CREDIT_BLOCK_EXPIRY - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiryLedgerEntry - .Metadata + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -479,42 +377,31 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry - ) - - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.incrementLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrementLedgerEntry()) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.expirationChangeLedgerEntry() - ) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiryLedgerEntry() - ) - .contains(creditBlockExpiryLedgerEntry) - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiatedLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendmentLedgerEntry()) - .isEmpty + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofCreditBlockExpiry( + creditBlockExpiry + ) + + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiry()) + .contains(creditBlockExpiry) + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendment()).isEmpty } @Test - fun ofCreditBlockExpiryLedgerEntryRoundtrip() { + fun ofCreditBlockExpiryRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofCreditBlockExpiryLedgerEntry( - CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiryLedgerEntry - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofCreditBlockExpiry( + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .CreditBlockExpiryLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry .CreditBlock .builder() .id("id") @@ -524,8 +411,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .CreditBlockExpiryLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry .Customer .builder() .id("id") @@ -535,21 +421,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .CreditBlockExpiryLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry .EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .CreditBlockExpiryLedgerEntry - .EntryType - .CREDIT_BLOCK_EXPIRY - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse - .CreditBlockExpiryLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.CreditBlockExpiry .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -570,15 +448,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { } @Test - fun ofVoidLedgerEntry() { - val voidLedgerEntry = - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.builder() + fun ofVoid() { + val void_ = + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -586,8 +463,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -595,17 +471,11 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.EntryType - .VOID + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -615,40 +485,28 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoidLedgerEntry(voidLedgerEntry) - - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.incrementLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrementLedgerEntry()) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.expirationChangeLedgerEntry() - ) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiryLedgerEntry() - ) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidLedgerEntry()) - .contains(voidLedgerEntry) - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiatedLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendmentLedgerEntry()) - .isEmpty + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoid(void_) + + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.void_()).contains(void_) + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendment()).isEmpty } @Test - fun ofVoidLedgerEntryRoundtrip() { + fun ofVoidRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoidLedgerEntry( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoid( + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -657,8 +515,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -666,19 +523,12 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry - .EntryType - .VOID - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Void.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -699,15 +549,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { } @Test - fun ofVoidInitiatedLedgerEntry() { - val voidInitiatedLedgerEntry = - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry.builder() + fun ofVoidInitiated() { + val voidInitiated = + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -716,8 +565,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry - .Customer + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -726,19 +574,12 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry - .EntryType - .VOID_INITIATED - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry - .Metadata + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -750,41 +591,29 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry - ) - - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.incrementLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrementLedgerEntry()) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.expirationChangeLedgerEntry() - ) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiryLedgerEntry() - ) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiatedLedgerEntry()) - .contains(voidInitiatedLedgerEntry) - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendmentLedgerEntry()) - .isEmpty + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoidInitiated(voidInitiated) + + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiated()) + .contains(voidInitiated) + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendment()).isEmpty } @Test - fun ofVoidInitiatedLedgerEntryRoundtrip() { + fun ofVoidInitiatedRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoidInitiatedLedgerEntry( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofVoidInitiated( + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated .CreditBlock .builder() .id("id") @@ -794,8 +623,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry - .Customer + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -804,19 +632,13 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated .EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry - .EntryType - .VOID_INITIATED - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiatedLedgerEntry - .Metadata + CustomerCreditLedgerCreateEntryByExternalIdResponse.VoidInitiated.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -839,15 +661,14 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { } @Test - fun ofAmendmentLedgerEntry() { - val amendmentLedgerEntry = - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry.builder() + fun ofAmendment() { + val amendment = + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -856,9 +677,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .Customer - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -866,20 +685,12 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .EntryType - .AMENDMENT - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .Metadata - .builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -887,41 +698,29 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .build() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofAmendmentLedgerEntry( - amendmentLedgerEntry - ) - - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.incrementLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrementLedgerEntry()) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.expirationChangeLedgerEntry() - ) - .isEmpty - assertThat( - customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiryLedgerEntry() - ) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiatedLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendmentLedgerEntry()) - .contains(amendmentLedgerEntry) + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofAmendment(amendment) + + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryByExternalIdResponse.amendment()) + .contains(amendment) } @Test - fun ofAmendmentLedgerEntryRoundtrip() { + fun ofAmendmentRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryByExternalIdResponse = - CustomerCreditLedgerCreateEntryByExternalIdResponse.ofAmendmentLedgerEntry( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry.builder() + CustomerCreditLedgerCreateEntryByExternalIdResponse.ofAmendment( + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -930,8 +729,7 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .Customer + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -940,19 +738,12 @@ internal class CustomerCreditLedgerCreateEntryByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .EntryType - .AMENDMENT - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdResponse.AmendmentLedgerEntry - .Metadata + CustomerCreditLedgerCreateEntryByExternalIdResponse.Amendment.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .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 d0a1eee9..2296b12a 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 @@ -14,24 +14,14 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") .body( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + CustomerCreditLedgerCreateEntryParams.Body.Increment.builder() .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) .currency("currency") .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .InvoiceSettings + CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() .autoCollection(true) .netTerms(0L) @@ -40,10 +30,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .Metadata - .builder() + CustomerCreditLedgerCreateEntryParams.Body.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -58,7 +45,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { val params = CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") - .addIncrementCreditLedgerEntryRequestParamsBody(0.0) + .incrementBody(0.0) .build() assertThat(params._pathParam(0)).isEqualTo("customer_id") @@ -72,24 +59,14 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") .body( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + CustomerCreditLedgerCreateEntryParams.Body.Increment.builder() .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) .currency("currency") .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .InvoiceSettings + CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() .autoCollection(true) .netTerms(0L) @@ -98,10 +75,7 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .Metadata - .builder() + CustomerCreditLedgerCreateEntryParams.Body.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -114,44 +88,30 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { assertThat(body) .isEqualTo( - CustomerCreditLedgerCreateEntryParams.Body - .ofAddIncrementCreditLedgerEntryRequestParams( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() - .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .currency("currency") - .description("description") - .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .InvoiceSettings - .builder() - .autoCollection(true) - .netTerms(0L) - .memo("memo") - .requireSuccessfulPayment(true) - .build() - ) - .metadata( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .Metadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .perUnitCostBasis("per_unit_cost_basis") - .build() - ) + CustomerCreditLedgerCreateEntryParams.Body.ofIncrement( + CustomerCreditLedgerCreateEntryParams.Body.Increment.builder() + .amount(0.0) + .currency("currency") + .description("description") + .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .invoiceSettings( + CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings + .builder() + .autoCollection(true) + .netTerms(0L) + .memo("memo") + .requireSuccessfulPayment(true) + .build() + ) + .metadata( + CustomerCreditLedgerCreateEntryParams.Body.Increment.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .perUnitCostBasis("per_unit_cost_basis") + .build() + ) ) } @@ -160,27 +120,18 @@ internal class CustomerCreditLedgerCreateEntryParamsTest { val params = CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") - .addIncrementCreditLedgerEntryRequestParamsBody(0.0) + .incrementBody(0.0) .build() val body = params._body() assertThat(body) .isEqualTo( - CustomerCreditLedgerCreateEntryParams.Body - .ofAddIncrementCreditLedgerEntryRequestParams( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() - .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) - .build() - ) + CustomerCreditLedgerCreateEntryParams.Body.ofIncrement( + CustomerCreditLedgerCreateEntryParams.Body.Increment.builder() + .amount(0.0) + .build() + ) ) } } 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 c9c9cd39..7e813252 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 @@ -16,15 +16,14 @@ import org.junit.jupiter.params.provider.EnumSource internal class CustomerCreditLedgerCreateEntryResponseTest { @Test - fun ofIncrementLedgerEntry() { - val incrementLedgerEntry = - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.builder() + fun ofIncrement() { + val increment = + CustomerCreditLedgerCreateEntryResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.Increment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -32,7 +31,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.Customer.builder() + CustomerCreditLedgerCreateEntryResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -40,15 +39,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.EntryType.INCREMENT + CustomerCreditLedgerCreateEntryResponse.Increment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.Metadata.builder() + CustomerCreditLedgerCreateEntryResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -56,30 +51,28 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofIncrementLedgerEntry(incrementLedgerEntry) - - assertThat(customerCreditLedgerCreateEntryResponse.incrementLedgerEntry()) - .contains(incrementLedgerEntry) - assertThat(customerCreditLedgerCreateEntryResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerCreateEntryResponse.ofIncrement(increment) + + assertThat(customerCreditLedgerCreateEntryResponse.increment()).contains(increment) + assertThat(customerCreditLedgerCreateEntryResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.amendment()).isEmpty } @Test - fun ofIncrementLedgerEntryRoundtrip() { + fun ofIncrementRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofIncrementLedgerEntry( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerCreateEntryResponse.ofIncrement( + CustomerCreditLedgerCreateEntryResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.Increment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -87,8 +80,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -96,17 +88,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.EntryType - .INCREMENT + CustomerCreditLedgerCreateEntryResponse.Increment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.IncrementLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -125,15 +111,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { } @Test - fun ofDecrementLedgerEntry() { - val decrementLedgerEntry = - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.builder() + fun ofDecrement() { + val decrement = + CustomerCreditLedgerCreateEntryResponse.Decrement.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.Decrement.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -141,7 +126,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.Customer.builder() + CustomerCreditLedgerCreateEntryResponse.Decrement.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -149,15 +134,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.EntryType.DECREMENT + CustomerCreditLedgerCreateEntryResponse.Decrement.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.Metadata.builder() + CustomerCreditLedgerCreateEntryResponse.Decrement.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -168,30 +149,28 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofDecrementLedgerEntry(decrementLedgerEntry) - - assertThat(customerCreditLedgerCreateEntryResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.decrementLedgerEntry()) - .contains(decrementLedgerEntry) - assertThat(customerCreditLedgerCreateEntryResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerCreateEntryResponse.ofDecrement(decrement) + + assertThat(customerCreditLedgerCreateEntryResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.decrement()).contains(decrement) + assertThat(customerCreditLedgerCreateEntryResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.amendment()).isEmpty } @Test - fun ofDecrementLedgerEntryRoundtrip() { + fun ofDecrementRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofDecrementLedgerEntry( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.builder() + CustomerCreditLedgerCreateEntryResponse.ofDecrement( + CustomerCreditLedgerCreateEntryResponse.Decrement.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.Decrement.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -199,8 +178,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryResponse.Decrement.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -208,17 +186,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.EntryType - .DECREMENT + CustomerCreditLedgerCreateEntryResponse.Decrement.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.DecrementLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryResponse.Decrement.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -240,15 +212,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { } @Test - fun ofExpirationChangeLedgerEntry() { - val expirationChangeLedgerEntry = - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.builder() + fun ofExpirationChange() { + val expirationChange = + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -256,8 +227,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -265,17 +235,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.EntryType - .EXPIRATION_CHANGE + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -284,32 +248,29 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry - ) - - assertThat(customerCreditLedgerCreateEntryResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.expirationChangeLedgerEntry()) - .contains(expirationChangeLedgerEntry) - assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerCreateEntryResponse.ofExpirationChange(expirationChange) + + assertThat(customerCreditLedgerCreateEntryResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.expirationChange()) + .contains(expirationChange) + assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.amendment()).isEmpty } @Test - fun ofExpirationChangeLedgerEntryRoundtrip() { + fun ofExpirationChangeRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofExpirationChangeLedgerEntry( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.builder() + CustomerCreditLedgerCreateEntryResponse.ofExpirationChange( + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -318,8 +279,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -327,19 +287,12 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry - .EntryType - .EXPIRATION_CHANGE - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.ExpirationChangeLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryResponse.ExpirationChange.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -359,15 +312,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { } @Test - fun ofCreditBlockExpiryLedgerEntry() { - val creditBlockExpiryLedgerEntry = - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry.builder() + fun ofCreditBlockExpiry() { + val creditBlockExpiry = + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -375,8 +327,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -384,17 +335,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry.EntryType - .CREDIT_BLOCK_EXPIRY + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -402,32 +347,29 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry - ) - - assertThat(customerCreditLedgerCreateEntryResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiryLedgerEntry()) - .contains(creditBlockExpiryLedgerEntry) - assertThat(customerCreditLedgerCreateEntryResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerCreateEntryResponse.ofCreditBlockExpiry(creditBlockExpiry) + + assertThat(customerCreditLedgerCreateEntryResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiry()) + .contains(creditBlockExpiry) + assertThat(customerCreditLedgerCreateEntryResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.amendment()).isEmpty } @Test - fun ofCreditBlockExpiryLedgerEntryRoundtrip() { + fun ofCreditBlockExpiryRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofCreditBlockExpiryLedgerEntry( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry.builder() + CustomerCreditLedgerCreateEntryResponse.ofCreditBlockExpiry( + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry - .CreditBlock + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -436,9 +378,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry - .Customer - .builder() + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -446,20 +386,12 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry - .EntryStatus + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry - .EntryType - .CREDIT_BLOCK_EXPIRY - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiryLedgerEntry - .Metadata - .builder() + CustomerCreditLedgerCreateEntryResponse.CreditBlockExpiry.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -478,14 +410,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { } @Test - fun ofVoidLedgerEntry() { - val voidLedgerEntry = - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.builder() + fun ofVoid() { + val void_ = + CustomerCreditLedgerCreateEntryResponse.Void.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerCreateEntryResponse.Void.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -493,20 +425,17 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.Customer.builder() + CustomerCreditLedgerCreateEntryResponse.Void.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.EntryStatus.COMMITTED - ) - .entryType(CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.EntryType.VOID) + .entryStatus(CustomerCreditLedgerCreateEntryResponse.Void.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.Metadata.builder() + CustomerCreditLedgerCreateEntryResponse.Void.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -516,30 +445,28 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofVoidLedgerEntry(voidLedgerEntry) - - assertThat(customerCreditLedgerCreateEntryResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidLedgerEntry()) - .contains(voidLedgerEntry) - assertThat(customerCreditLedgerCreateEntryResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerCreateEntryResponse.ofVoid(void_) + + assertThat(customerCreditLedgerCreateEntryResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.void_()).contains(void_) + assertThat(customerCreditLedgerCreateEntryResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.amendment()).isEmpty } @Test - fun ofVoidLedgerEntryRoundtrip() { + fun ofVoidRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofVoidLedgerEntry( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.builder() + CustomerCreditLedgerCreateEntryResponse.ofVoid( + CustomerCreditLedgerCreateEntryResponse.Void.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.Void.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -547,23 +474,17 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.Customer.builder() + CustomerCreditLedgerCreateEntryResponse.Void.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.EntryType.VOID - ) + .entryStatus(CustomerCreditLedgerCreateEntryResponse.Void.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.VoidLedgerEntry.Metadata.builder() + CustomerCreditLedgerCreateEntryResponse.Void.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -584,15 +505,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { } @Test - fun ofVoidInitiatedLedgerEntry() { - val voidInitiatedLedgerEntry = - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.builder() + fun ofVoidInitiated() { + val voidInitiated = + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -600,8 +520,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -609,17 +528,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.EntryType - .VOID_INITIATED + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -630,32 +543,28 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry - ) - - assertThat(customerCreditLedgerCreateEntryResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidInitiatedLedgerEntry()) - .contains(voidInitiatedLedgerEntry) - assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerCreateEntryResponse.ofVoidInitiated(voidInitiated) + + assertThat(customerCreditLedgerCreateEntryResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.voidInitiated()).contains(voidInitiated) + assertThat(customerCreditLedgerCreateEntryResponse.amendment()).isEmpty } @Test - fun ofVoidInitiatedLedgerEntryRoundtrip() { + fun ofVoidInitiatedRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofVoidInitiatedLedgerEntry( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.builder() + CustomerCreditLedgerCreateEntryResponse.ofVoidInitiated( + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -663,8 +572,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -672,17 +580,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.EntryType - .VOID_INITIATED + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.VoidInitiatedLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryResponse.VoidInitiated.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -704,15 +606,14 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { } @Test - fun ofAmendmentLedgerEntry() { - val amendmentLedgerEntry = - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.builder() + fun ofAmendment() { + val amendment = + CustomerCreditLedgerCreateEntryResponse.Amendment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.Amendment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -720,7 +621,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.Customer.builder() + CustomerCreditLedgerCreateEntryResponse.Amendment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -728,15 +629,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.EntryType.AMENDMENT + CustomerCreditLedgerCreateEntryResponse.Amendment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.Metadata.builder() + CustomerCreditLedgerCreateEntryResponse.Amendment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -744,30 +641,28 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .build() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofAmendmentLedgerEntry(amendmentLedgerEntry) - - assertThat(customerCreditLedgerCreateEntryResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerCreateEntryResponse.amendmentLedgerEntry()) - .contains(amendmentLedgerEntry) + CustomerCreditLedgerCreateEntryResponse.ofAmendment(amendment) + + assertThat(customerCreditLedgerCreateEntryResponse.increment()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.decrement()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.void_()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerCreateEntryResponse.amendment()).contains(amendment) } @Test - fun ofAmendmentLedgerEntryRoundtrip() { + fun ofAmendmentRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerCreateEntryResponse = - CustomerCreditLedgerCreateEntryResponse.ofAmendmentLedgerEntry( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.builder() + CustomerCreditLedgerCreateEntryResponse.ofAmendment( + CustomerCreditLedgerCreateEntryResponse.Amendment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerCreateEntryResponse.Amendment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -775,8 +670,7 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.Customer - .builder() + CustomerCreditLedgerCreateEntryResponse.Amendment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -784,17 +678,11 @@ internal class CustomerCreditLedgerCreateEntryResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.EntryType - .AMENDMENT + CustomerCreditLedgerCreateEntryResponse.Amendment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerCreateEntryResponse.AmendmentLedgerEntry.Metadata - .builder() + CustomerCreditLedgerCreateEntryResponse.Amendment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .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 40ee16c7..be1f12c7 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 @@ -16,13 +16,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { val customerCreditLedgerListByExternalIdPageResponse = CustomerCreditLedgerListByExternalIdPageResponse.builder() .addData( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .CreditBlock + CustomerCreditLedgerListByExternalIdResponse.Increment.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -31,8 +30,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .Customer + CustomerCreditLedgerListByExternalIdResponse.Increment.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -41,19 +39,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .EntryStatus + CustomerCreditLedgerListByExternalIdResponse.Increment.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .EntryType - .INCREMENT - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .Metadata + CustomerCreditLedgerListByExternalIdResponse.Increment.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -68,14 +59,13 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { assertThat(customerCreditLedgerListByExternalIdPageResponse.data()) .containsExactly( - CustomerCreditLedgerListByExternalIdResponse.ofIncrementLedgerEntry( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.ofIncrement( + CustomerCreditLedgerListByExternalIdResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .CreditBlock + CustomerCreditLedgerListByExternalIdResponse.Increment.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -84,8 +74,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .Customer + CustomerCreditLedgerListByExternalIdResponse.Increment.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -94,19 +83,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .EntryStatus + CustomerCreditLedgerListByExternalIdResponse.Increment.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .EntryType - .INCREMENT - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .Metadata + CustomerCreditLedgerListByExternalIdResponse.Increment.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -125,13 +107,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { val customerCreditLedgerListByExternalIdPageResponse = CustomerCreditLedgerListByExternalIdPageResponse.builder() .addData( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .CreditBlock + CustomerCreditLedgerListByExternalIdResponse.Increment.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -140,8 +121,7 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .Customer + CustomerCreditLedgerListByExternalIdResponse.Increment.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -150,19 +130,12 @@ internal class CustomerCreditLedgerListByExternalIdPageResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .EntryStatus + CustomerCreditLedgerListByExternalIdResponse.Increment.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .EntryType - .INCREMENT - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .Metadata + CustomerCreditLedgerListByExternalIdResponse.Increment.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .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 6b221082..3e049321 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 @@ -16,15 +16,14 @@ import org.junit.jupiter.params.provider.EnumSource internal class CustomerCreditLedgerListByExternalIdResponseTest { @Test - fun ofIncrementLedgerEntry() { - val incrementLedgerEntry = - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.builder() + fun ofIncrement() { + val increment = + CustomerCreditLedgerListByExternalIdResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListByExternalIdResponse.Increment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -32,8 +31,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.Customer - .builder() + CustomerCreditLedgerListByExternalIdResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -41,17 +39,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.EntryType - .INCREMENT + CustomerCreditLedgerListByExternalIdResponse.Increment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListByExternalIdResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -59,35 +51,28 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofIncrementLedgerEntry( - incrementLedgerEntry - ) - - assertThat(customerCreditLedgerListByExternalIdResponse.incrementLedgerEntry()) - .contains(incrementLedgerEntry) - assertThat(customerCreditLedgerListByExternalIdResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.expirationChangeLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiryLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListByExternalIdResponse.ofIncrement(increment) + + assertThat(customerCreditLedgerListByExternalIdResponse.increment()).contains(increment) + assertThat(customerCreditLedgerListByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.amendment()).isEmpty } @Test - fun ofIncrementLedgerEntryRoundtrip() { + fun ofIncrementRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofIncrementLedgerEntry( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.ofIncrement( + CustomerCreditLedgerListByExternalIdResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .CreditBlock - .builder() + CustomerCreditLedgerListByExternalIdResponse.Increment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -95,8 +80,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.Customer - .builder() + CustomerCreditLedgerListByExternalIdResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -104,18 +88,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry - .EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.EntryType - .INCREMENT + CustomerCreditLedgerListByExternalIdResponse.Increment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.IncrementLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListByExternalIdResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -134,15 +111,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { } @Test - fun ofDecrementLedgerEntry() { - val decrementLedgerEntry = - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.builder() + fun ofDecrement() { + val decrement = + CustomerCreditLedgerListByExternalIdResponse.Decrement.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListByExternalIdResponse.Decrement.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -150,8 +126,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.Customer - .builder() + CustomerCreditLedgerListByExternalIdResponse.Decrement.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -159,17 +134,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.EntryType - .DECREMENT + CustomerCreditLedgerListByExternalIdResponse.Decrement.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListByExternalIdResponse.Decrement.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -180,35 +149,28 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofDecrementLedgerEntry( - decrementLedgerEntry - ) - - assertThat(customerCreditLedgerListByExternalIdResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.decrementLedgerEntry()) - .contains(decrementLedgerEntry) - assertThat(customerCreditLedgerListByExternalIdResponse.expirationChangeLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiryLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListByExternalIdResponse.ofDecrement(decrement) + + assertThat(customerCreditLedgerListByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.decrement()).contains(decrement) + assertThat(customerCreditLedgerListByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.amendment()).isEmpty } @Test - fun ofDecrementLedgerEntryRoundtrip() { + fun ofDecrementRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofDecrementLedgerEntry( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.ofDecrement( + CustomerCreditLedgerListByExternalIdResponse.Decrement.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry - .CreditBlock - .builder() + CustomerCreditLedgerListByExternalIdResponse.Decrement.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -216,8 +178,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.Customer - .builder() + CustomerCreditLedgerListByExternalIdResponse.Decrement.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -225,18 +186,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry - .EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.EntryType - .DECREMENT + CustomerCreditLedgerListByExternalIdResponse.Decrement.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.DecrementLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListByExternalIdResponse.Decrement.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -258,15 +212,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { } @Test - fun ofExpirationChangeLedgerEntry() { - val expirationChangeLedgerEntry = - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry.builder() + fun ofExpirationChange() { + val expirationChange = + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .CreditBlock + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -275,9 +228,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .Customer - .builder() + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -285,20 +236,12 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .EntryStatus + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .EntryType - .EXPIRATION_CHANGE - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .Metadata - .builder() + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -307,33 +250,29 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry - ) - - assertThat(customerCreditLedgerListByExternalIdResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.expirationChangeLedgerEntry()) - .contains(expirationChangeLedgerEntry) - assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiryLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListByExternalIdResponse.ofExpirationChange(expirationChange) + + assertThat(customerCreditLedgerListByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.expirationChange()) + .contains(expirationChange) + assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.amendment()).isEmpty } @Test - fun ofExpirationChangeLedgerEntryRoundtrip() { + fun ofExpirationChangeRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofExpirationChangeLedgerEntry( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.ofExpirationChange( + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .CreditBlock + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -342,8 +281,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .Customer + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -352,19 +290,12 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .EntryStatus + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .EntryType - .EXPIRATION_CHANGE - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.ExpirationChangeLedgerEntry - .Metadata + CustomerCreditLedgerListByExternalIdResponse.ExpirationChange.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -385,15 +316,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { } @Test - fun ofCreditBlockExpiryLedgerEntry() { - val creditBlockExpiryLedgerEntry = - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry.builder() + fun ofCreditBlockExpiry() { + val creditBlockExpiry = + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .CreditBlock + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -402,8 +332,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .Customer + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -412,19 +341,12 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .EntryStatus + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .EntryType - .CREDIT_BLOCK_EXPIRY - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .Metadata + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -433,33 +355,29 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry - ) - - assertThat(customerCreditLedgerListByExternalIdResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.expirationChangeLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiryLedgerEntry()) - .contains(creditBlockExpiryLedgerEntry) - assertThat(customerCreditLedgerListByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListByExternalIdResponse.ofCreditBlockExpiry(creditBlockExpiry) + + assertThat(customerCreditLedgerListByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiry()) + .contains(creditBlockExpiry) + assertThat(customerCreditLedgerListByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.amendment()).isEmpty } @Test - fun ofCreditBlockExpiryLedgerEntryRoundtrip() { + fun ofCreditBlockExpiryRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofCreditBlockExpiryLedgerEntry( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.ofCreditBlockExpiry( + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .CreditBlock + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -468,8 +386,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .Customer + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -478,19 +395,12 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .EntryStatus + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .EntryType - .CREDIT_BLOCK_EXPIRY - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiryLedgerEntry - .Metadata + CustomerCreditLedgerListByExternalIdResponse.CreditBlockExpiry.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -510,15 +420,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { } @Test - fun ofVoidLedgerEntry() { - val voidLedgerEntry = - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.builder() + fun ofVoid() { + val void_ = + CustomerCreditLedgerListByExternalIdResponse.Void.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListByExternalIdResponse.Void.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -526,7 +435,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.Customer.builder() + CustomerCreditLedgerListByExternalIdResponse.Void.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -534,15 +443,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.EntryType.VOID + CustomerCreditLedgerListByExternalIdResponse.Void.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.Metadata.builder() + CustomerCreditLedgerListByExternalIdResponse.Void.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -552,32 +457,28 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofVoidLedgerEntry(voidLedgerEntry) - - assertThat(customerCreditLedgerListByExternalIdResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.expirationChangeLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiryLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidLedgerEntry()) - .contains(voidLedgerEntry) - assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListByExternalIdResponse.ofVoid(void_) + + assertThat(customerCreditLedgerListByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.void_()).contains(void_) + assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.amendment()).isEmpty } @Test - fun ofVoidLedgerEntryRoundtrip() { + fun ofVoidRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofVoidLedgerEntry( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.ofVoid( + CustomerCreditLedgerListByExternalIdResponse.Void.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListByExternalIdResponse.Void.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -585,8 +486,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.Customer - .builder() + CustomerCreditLedgerListByExternalIdResponse.Void.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -594,16 +494,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.EntryType.VOID + CustomerCreditLedgerListByExternalIdResponse.Void.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.VoidLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListByExternalIdResponse.Void.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -624,16 +519,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { } @Test - fun ofVoidInitiatedLedgerEntry() { - val voidInitiatedLedgerEntry = - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry.builder() + fun ofVoidInitiated() { + val voidInitiated = + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry - .CreditBlock - .builder() + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -641,8 +534,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry.Customer - .builder() + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -650,18 +542,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry - .EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry.EntryType - .VOID_INITIATED + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -672,34 +557,29 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofVoidInitiatedLedgerEntry( - voidInitiatedLedgerEntry - ) - - assertThat(customerCreditLedgerListByExternalIdResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.expirationChangeLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiryLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiatedLedgerEntry()) - .contains(voidInitiatedLedgerEntry) - assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListByExternalIdResponse.ofVoidInitiated(voidInitiated) + + assertThat(customerCreditLedgerListByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiated()) + .contains(voidInitiated) + assertThat(customerCreditLedgerListByExternalIdResponse.amendment()).isEmpty } @Test - fun ofVoidInitiatedLedgerEntryRoundtrip() { + fun ofVoidInitiatedRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofVoidInitiatedLedgerEntry( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.ofVoidInitiated( + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry - .CreditBlock + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.CreditBlock .builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -708,8 +588,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry - .Customer + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.Customer .builder() .id("id") .externalCustomerId("external_customer_id") @@ -718,19 +597,12 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry - .EntryStatus + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.EntryStatus .COMMITTED ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry - .EntryType - .VOID_INITIATED - ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.VoidInitiatedLedgerEntry - .Metadata + CustomerCreditLedgerListByExternalIdResponse.VoidInitiated.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -753,15 +625,14 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { } @Test - fun ofAmendmentLedgerEntry() { - val amendmentLedgerEntry = - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.builder() + fun ofAmendment() { + val amendment = + CustomerCreditLedgerListByExternalIdResponse.Amendment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListByExternalIdResponse.Amendment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -769,8 +640,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.Customer - .builder() + CustomerCreditLedgerListByExternalIdResponse.Amendment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -778,17 +648,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.EntryType - .AMENDMENT + CustomerCreditLedgerListByExternalIdResponse.Amendment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListByExternalIdResponse.Amendment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -796,35 +660,28 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .build() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofAmendmentLedgerEntry( - amendmentLedgerEntry - ) - - assertThat(customerCreditLedgerListByExternalIdResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.expirationChangeLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiryLedgerEntry()) - .isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListByExternalIdResponse.amendmentLedgerEntry()) - .contains(amendmentLedgerEntry) + CustomerCreditLedgerListByExternalIdResponse.ofAmendment(amendment) + + assertThat(customerCreditLedgerListByExternalIdResponse.increment()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.void_()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListByExternalIdResponse.amendment()).contains(amendment) } @Test - fun ofAmendmentLedgerEntryRoundtrip() { + fun ofAmendmentRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListByExternalIdResponse = - CustomerCreditLedgerListByExternalIdResponse.ofAmendmentLedgerEntry( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.builder() + CustomerCreditLedgerListByExternalIdResponse.ofAmendment( + CustomerCreditLedgerListByExternalIdResponse.Amendment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry - .CreditBlock - .builder() + CustomerCreditLedgerListByExternalIdResponse.Amendment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -832,8 +689,7 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.Customer - .builder() + CustomerCreditLedgerListByExternalIdResponse.Amendment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -841,18 +697,11 @@ internal class CustomerCreditLedgerListByExternalIdResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry - .EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.EntryType - .AMENDMENT + CustomerCreditLedgerListByExternalIdResponse.Amendment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListByExternalIdResponse.AmendmentLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListByExternalIdResponse.Amendment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .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 44788165..0fa1974e 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 @@ -16,13 +16,12 @@ internal class CustomerCreditLedgerListPageResponseTest { val customerCreditLedgerListPageResponse = CustomerCreditLedgerListPageResponse.builder() .addData( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerListResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListResponse.Increment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -30,7 +29,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -38,16 +37,11 @@ internal class CustomerCreditLedgerListPageResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryType - .INCREMENT + CustomerCreditLedgerListResponse.Increment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -61,14 +55,13 @@ internal class CustomerCreditLedgerListPageResponseTest { assertThat(customerCreditLedgerListPageResponse.data()) .containsExactly( - CustomerCreditLedgerListResponse.ofIncrementLedgerEntry( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerListResponse.ofIncrement( + CustomerCreditLedgerListResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListResponse.Increment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -76,7 +69,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -84,16 +77,11 @@ internal class CustomerCreditLedgerListPageResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryType - .INCREMENT + CustomerCreditLedgerListResponse.Increment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -111,13 +99,12 @@ internal class CustomerCreditLedgerListPageResponseTest { val customerCreditLedgerListPageResponse = CustomerCreditLedgerListPageResponse.builder() .addData( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerListResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListResponse.Increment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -125,7 +112,7 @@ internal class CustomerCreditLedgerListPageResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -133,16 +120,11 @@ internal class CustomerCreditLedgerListPageResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryType - .INCREMENT + CustomerCreditLedgerListResponse.Increment.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .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 0e452a16..fb6f1025 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 @@ -16,14 +16,14 @@ import org.junit.jupiter.params.provider.EnumSource internal class CustomerCreditLedgerListResponseTest { @Test - fun ofIncrementLedgerEntry() { - val incrementLedgerEntry = - CustomerCreditLedgerListResponse.IncrementLedgerEntry.builder() + fun ofIncrement() { + val increment = + CustomerCreditLedgerListResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerListResponse.Increment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -31,22 +31,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryStatus.COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryType.INCREMENT - ) + .entryStatus(CustomerCreditLedgerListResponse.Increment.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -54,29 +49,28 @@ internal class CustomerCreditLedgerListResponseTest { .build() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofIncrementLedgerEntry(incrementLedgerEntry) - - assertThat(customerCreditLedgerListResponse.incrementLedgerEntry()) - .contains(incrementLedgerEntry) - assertThat(customerCreditLedgerListResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListResponse.ofIncrement(increment) + + assertThat(customerCreditLedgerListResponse.increment()).contains(increment) + assertThat(customerCreditLedgerListResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListResponse.void_()).isEmpty + assertThat(customerCreditLedgerListResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListResponse.amendment()).isEmpty } @Test - fun ofIncrementLedgerEntryRoundtrip() { + fun ofIncrementRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofIncrementLedgerEntry( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.builder() + CustomerCreditLedgerListResponse.ofIncrement( + CustomerCreditLedgerListResponse.Increment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerListResponse.Increment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -84,22 +78,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Increment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryStatus.COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.EntryType.INCREMENT - ) + .entryStatus(CustomerCreditLedgerListResponse.Increment.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.IncrementLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Increment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -118,14 +107,14 @@ internal class CustomerCreditLedgerListResponseTest { } @Test - fun ofDecrementLedgerEntry() { - val decrementLedgerEntry = - CustomerCreditLedgerListResponse.DecrementLedgerEntry.builder() + fun ofDecrement() { + val decrement = + CustomerCreditLedgerListResponse.Decrement.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerListResponse.Decrement.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -133,22 +122,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Decrement.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.EntryStatus.COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.EntryType.DECREMENT - ) + .entryStatus(CustomerCreditLedgerListResponse.Decrement.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Decrement.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -159,29 +143,28 @@ internal class CustomerCreditLedgerListResponseTest { .build() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofDecrementLedgerEntry(decrementLedgerEntry) - - assertThat(customerCreditLedgerListResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.decrementLedgerEntry()) - .contains(decrementLedgerEntry) - assertThat(customerCreditLedgerListResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListResponse.ofDecrement(decrement) + + assertThat(customerCreditLedgerListResponse.increment()).isEmpty + assertThat(customerCreditLedgerListResponse.decrement()).contains(decrement) + assertThat(customerCreditLedgerListResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListResponse.void_()).isEmpty + assertThat(customerCreditLedgerListResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListResponse.amendment()).isEmpty } @Test - fun ofDecrementLedgerEntryRoundtrip() { + fun ofDecrementRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofDecrementLedgerEntry( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.builder() + CustomerCreditLedgerListResponse.ofDecrement( + CustomerCreditLedgerListResponse.Decrement.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerListResponse.Decrement.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -189,22 +172,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Decrement.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.EntryStatus.COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.EntryType.DECREMENT - ) + .entryStatus(CustomerCreditLedgerListResponse.Decrement.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.DecrementLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Decrement.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -226,15 +204,14 @@ internal class CustomerCreditLedgerListResponseTest { } @Test - fun ofExpirationChangeLedgerEntry() { - val expirationChangeLedgerEntry = - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.builder() + fun ofExpirationChange() { + val expirationChange = + CustomerCreditLedgerListResponse.ExpirationChange.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListResponse.ExpirationChange.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -242,7 +219,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.ExpirationChange.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -250,16 +227,11 @@ internal class CustomerCreditLedgerListResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.EntryType - .EXPIRATION_CHANGE + CustomerCreditLedgerListResponse.ExpirationChange.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.ExpirationChange.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -268,32 +240,28 @@ internal class CustomerCreditLedgerListResponseTest { .build() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofExpirationChangeLedgerEntry( - expirationChangeLedgerEntry - ) - - assertThat(customerCreditLedgerListResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.expirationChangeLedgerEntry()) - .contains(expirationChangeLedgerEntry) - assertThat(customerCreditLedgerListResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListResponse.ofExpirationChange(expirationChange) + + assertThat(customerCreditLedgerListResponse.increment()).isEmpty + assertThat(customerCreditLedgerListResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListResponse.expirationChange()).contains(expirationChange) + assertThat(customerCreditLedgerListResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListResponse.void_()).isEmpty + assertThat(customerCreditLedgerListResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListResponse.amendment()).isEmpty } @Test - fun ofExpirationChangeLedgerEntryRoundtrip() { + fun ofExpirationChangeRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofExpirationChangeLedgerEntry( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.builder() + CustomerCreditLedgerListResponse.ofExpirationChange( + CustomerCreditLedgerListResponse.ExpirationChange.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListResponse.ExpirationChange.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -301,8 +269,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.Customer - .builder() + CustomerCreditLedgerListResponse.ExpirationChange.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -310,17 +277,11 @@ internal class CustomerCreditLedgerListResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.EntryType - .EXPIRATION_CHANGE + CustomerCreditLedgerListResponse.ExpirationChange.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.ExpirationChangeLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListResponse.ExpirationChange.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -340,15 +301,14 @@ internal class CustomerCreditLedgerListResponseTest { } @Test - fun ofCreditBlockExpiryLedgerEntry() { - val creditBlockExpiryLedgerEntry = - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.builder() + fun ofCreditBlockExpiry() { + val creditBlockExpiry = + CustomerCreditLedgerListResponse.CreditBlockExpiry.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListResponse.CreditBlockExpiry.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -356,7 +316,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.CreditBlockExpiry.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -364,16 +324,11 @@ internal class CustomerCreditLedgerListResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.EntryType - .CREDIT_BLOCK_EXPIRY + CustomerCreditLedgerListResponse.CreditBlockExpiry.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.CreditBlockExpiry.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -381,32 +336,28 @@ internal class CustomerCreditLedgerListResponseTest { .build() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofCreditBlockExpiryLedgerEntry( - creditBlockExpiryLedgerEntry - ) - - assertThat(customerCreditLedgerListResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.creditBlockExpiryLedgerEntry()) - .contains(creditBlockExpiryLedgerEntry) - assertThat(customerCreditLedgerListResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListResponse.ofCreditBlockExpiry(creditBlockExpiry) + + assertThat(customerCreditLedgerListResponse.increment()).isEmpty + assertThat(customerCreditLedgerListResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListResponse.creditBlockExpiry()).contains(creditBlockExpiry) + assertThat(customerCreditLedgerListResponse.void_()).isEmpty + assertThat(customerCreditLedgerListResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListResponse.amendment()).isEmpty } @Test - fun ofCreditBlockExpiryLedgerEntryRoundtrip() { + fun ofCreditBlockExpiryRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofCreditBlockExpiryLedgerEntry( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.builder() + CustomerCreditLedgerListResponse.ofCreditBlockExpiry( + CustomerCreditLedgerListResponse.CreditBlockExpiry.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListResponse.CreditBlockExpiry.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -414,8 +365,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.Customer - .builder() + CustomerCreditLedgerListResponse.CreditBlockExpiry.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -423,17 +373,11 @@ internal class CustomerCreditLedgerListResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.EntryType - .CREDIT_BLOCK_EXPIRY + CustomerCreditLedgerListResponse.CreditBlockExpiry.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.CreditBlockExpiryLedgerEntry.Metadata - .builder() + CustomerCreditLedgerListResponse.CreditBlockExpiry.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -452,14 +396,14 @@ internal class CustomerCreditLedgerListResponseTest { } @Test - fun ofVoidLedgerEntry() { - val voidLedgerEntry = - CustomerCreditLedgerListResponse.VoidLedgerEntry.builder() + fun ofVoid() { + val void_ = + CustomerCreditLedgerListResponse.Void.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.VoidLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerListResponse.Void.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -467,18 +411,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.VoidLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Void.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus(CustomerCreditLedgerListResponse.VoidLedgerEntry.EntryStatus.COMMITTED) - .entryType(CustomerCreditLedgerListResponse.VoidLedgerEntry.EntryType.VOID) + .entryStatus(CustomerCreditLedgerListResponse.Void.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.VoidLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Void.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -487,29 +430,28 @@ internal class CustomerCreditLedgerListResponseTest { .voidReason("void_reason") .build() - val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofVoidLedgerEntry(voidLedgerEntry) - - assertThat(customerCreditLedgerListResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidLedgerEntry()).contains(voidLedgerEntry) - assertThat(customerCreditLedgerListResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty + val customerCreditLedgerListResponse = CustomerCreditLedgerListResponse.ofVoid(void_) + + assertThat(customerCreditLedgerListResponse.increment()).isEmpty + assertThat(customerCreditLedgerListResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListResponse.void_()).contains(void_) + assertThat(customerCreditLedgerListResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListResponse.amendment()).isEmpty } @Test - fun ofVoidLedgerEntryRoundtrip() { + fun ofVoidRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofVoidLedgerEntry( - CustomerCreditLedgerListResponse.VoidLedgerEntry.builder() + CustomerCreditLedgerListResponse.ofVoid( + CustomerCreditLedgerListResponse.Void.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.VoidLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerListResponse.Void.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -517,20 +459,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.VoidLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Void.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerListResponse.VoidLedgerEntry.EntryStatus.COMMITTED - ) - .entryType(CustomerCreditLedgerListResponse.VoidLedgerEntry.EntryType.VOID) + .entryStatus(CustomerCreditLedgerListResponse.Void.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.VoidLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Void.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -551,14 +490,14 @@ internal class CustomerCreditLedgerListResponseTest { } @Test - fun ofVoidInitiatedLedgerEntry() { - val voidInitiatedLedgerEntry = - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.builder() + fun ofVoidInitiated() { + val voidInitiated = + CustomerCreditLedgerListResponse.VoidInitiated.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerListResponse.VoidInitiated.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -566,23 +505,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.VoidInitiated.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.EntryStatus.COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.EntryType - .VOID_INITIATED - ) + .entryStatus(CustomerCreditLedgerListResponse.VoidInitiated.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.VoidInitiated.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -593,30 +526,28 @@ internal class CustomerCreditLedgerListResponseTest { .build() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofVoidInitiatedLedgerEntry(voidInitiatedLedgerEntry) - - assertThat(customerCreditLedgerListResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidInitiatedLedgerEntry()) - .contains(voidInitiatedLedgerEntry) - assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()).isEmpty + CustomerCreditLedgerListResponse.ofVoidInitiated(voidInitiated) + + assertThat(customerCreditLedgerListResponse.increment()).isEmpty + assertThat(customerCreditLedgerListResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListResponse.void_()).isEmpty + assertThat(customerCreditLedgerListResponse.voidInitiated()).contains(voidInitiated) + assertThat(customerCreditLedgerListResponse.amendment()).isEmpty } @Test - fun ofVoidInitiatedLedgerEntryRoundtrip() { + fun ofVoidInitiatedRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofVoidInitiatedLedgerEntry( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.builder() + CustomerCreditLedgerListResponse.ofVoidInitiated( + CustomerCreditLedgerListResponse.VoidInitiated.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.CreditBlock - .builder() + CustomerCreditLedgerListResponse.VoidInitiated.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -624,7 +555,7 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.VoidInitiated.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() @@ -632,16 +563,11 @@ internal class CustomerCreditLedgerListResponseTest { .description("description") .endingBalance(0.0) .entryStatus( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.EntryStatus - .COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.EntryType - .VOID_INITIATED + CustomerCreditLedgerListResponse.VoidInitiated.EntryStatus.COMMITTED ) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.VoidInitiatedLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.VoidInitiated.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -663,14 +589,14 @@ internal class CustomerCreditLedgerListResponseTest { } @Test - fun ofAmendmentLedgerEntry() { - val amendmentLedgerEntry = - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.builder() + fun ofAmendment() { + val amendment = + CustomerCreditLedgerListResponse.Amendment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerListResponse.Amendment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -678,22 +604,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Amendment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.EntryStatus.COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.EntryType.AMENDMENT - ) + .entryStatus(CustomerCreditLedgerListResponse.Amendment.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Amendment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -701,29 +622,28 @@ internal class CustomerCreditLedgerListResponseTest { .build() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofAmendmentLedgerEntry(amendmentLedgerEntry) - - assertThat(customerCreditLedgerListResponse.incrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.decrementLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.expirationChangeLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.creditBlockExpiryLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.voidInitiatedLedgerEntry()).isEmpty - assertThat(customerCreditLedgerListResponse.amendmentLedgerEntry()) - .contains(amendmentLedgerEntry) + CustomerCreditLedgerListResponse.ofAmendment(amendment) + + assertThat(customerCreditLedgerListResponse.increment()).isEmpty + assertThat(customerCreditLedgerListResponse.decrement()).isEmpty + assertThat(customerCreditLedgerListResponse.expirationChange()).isEmpty + assertThat(customerCreditLedgerListResponse.creditBlockExpiry()).isEmpty + assertThat(customerCreditLedgerListResponse.void_()).isEmpty + assertThat(customerCreditLedgerListResponse.voidInitiated()).isEmpty + assertThat(customerCreditLedgerListResponse.amendment()).contains(amendment) } @Test - fun ofAmendmentLedgerEntryRoundtrip() { + fun ofAmendmentRoundtrip() { val jsonMapper = jsonMapper() val customerCreditLedgerListResponse = - CustomerCreditLedgerListResponse.ofAmendmentLedgerEntry( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.builder() + CustomerCreditLedgerListResponse.ofAmendment( + CustomerCreditLedgerListResponse.Amendment.builder() .id("id") .amount(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditBlock( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.CreditBlock.builder() + CustomerCreditLedgerListResponse.Amendment.CreditBlock.builder() .id("id") .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .perUnitCostBasis("per_unit_cost_basis") @@ -731,22 +651,17 @@ internal class CustomerCreditLedgerListResponseTest { ) .currency("currency") .customer( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.Customer.builder() + CustomerCreditLedgerListResponse.Amendment.Customer.builder() .id("id") .externalCustomerId("external_customer_id") .build() ) .description("description") .endingBalance(0.0) - .entryStatus( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.EntryStatus.COMMITTED - ) - .entryType( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.EntryType.AMENDMENT - ) + .entryStatus(CustomerCreditLedgerListResponse.Amendment.EntryStatus.COMMITTED) .ledgerSequenceNumber(0L) .metadata( - CustomerCreditLedgerListResponse.AmendmentLedgerEntry.Metadata.builder() + CustomerCreditLedgerListResponse.Amendment.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) 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 d94ab291..5d92e224 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 @@ -72,14 +72,8 @@ internal class CustomerUpdateByExternalIdParamsTest { .build() ) .taxConfiguration( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerUpdateByExternalIdParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -166,15 +160,8 @@ internal class CustomerUpdateByExternalIdParamsTest { .build() ) .taxConfiguration( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerUpdateByExternalIdParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -256,16 +243,9 @@ internal class CustomerUpdateByExternalIdParamsTest { ) assertThat(body.taxConfiguration()) .contains( - CustomerUpdateByExternalIdParams.TaxConfiguration.ofNewAvalara( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerUpdateByExternalIdParams.TaxConfiguration.ofAvalara( + CustomerUpdateByExternalIdParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) 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 ff2724f9..e6dbea3f 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 @@ -69,12 +69,8 @@ internal class CustomerUpdateParamsTest { .build() ) .taxConfiguration( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerUpdateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -158,13 +154,8 @@ internal class CustomerUpdateParamsTest { .build() ) .taxConfiguration( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerUpdateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -240,14 +231,9 @@ internal class CustomerUpdateParamsTest { ) assertThat(body.taxConfiguration()) .contains( - CustomerUpdateParams.TaxConfiguration.ofNewAvalara( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerUpdateParams.TaxConfiguration.ofAvalara( + CustomerUpdateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) 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 d33b6b2a..21fb428d 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 @@ -113,16 +113,8 @@ internal class InvoiceFetchUpcomingResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + InvoiceFetchUpcomingResponse.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -161,25 +153,24 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -197,45 +188,43 @@ internal class InvoiceFetchUpcomingResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -245,12 +234,10 @@ internal class InvoiceFetchUpcomingResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .builder() + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem - .MatrixSubLineItem + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -258,8 +245,7 @@ internal class InvoiceFetchUpcomingResponseTest { .build() ) .matrixConfig( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem - .MatrixSubLineItem + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -267,12 +253,6 @@ internal class InvoiceFetchUpcomingResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -458,16 +438,8 @@ internal class InvoiceFetchUpcomingResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + InvoiceFetchUpcomingResponse.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -506,24 +478,22 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -541,44 +511,41 @@ internal class InvoiceFetchUpcomingResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -588,19 +555,17 @@ internal class InvoiceFetchUpcomingResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .builder() + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -608,11 +573,6 @@ internal class InvoiceFetchUpcomingResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -801,16 +761,8 @@ internal class InvoiceFetchUpcomingResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + InvoiceFetchUpcomingResponse.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - InvoiceFetchUpcomingResponse.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -849,25 +801,24 @@ internal class InvoiceFetchUpcomingResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -885,45 +836,43 @@ internal class InvoiceFetchUpcomingResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -933,12 +882,10 @@ internal class InvoiceFetchUpcomingResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem.MatrixSubLineItem - .builder() + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem - .MatrixSubLineItem + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -946,8 +893,7 @@ internal class InvoiceFetchUpcomingResponseTest { .build() ) .matrixConfig( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem - .MatrixSubLineItem + InvoiceFetchUpcomingResponse.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -955,12 +901,6 @@ internal class InvoiceFetchUpcomingResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - InvoiceFetchUpcomingResponse.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") 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 9e4c6a5c..61716a1e 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 @@ -19,14 +19,8 @@ internal class InvoiceLineItemCreateResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + InvoiceLineItemCreateResponse.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -65,22 +59,20 @@ internal class InvoiceLineItemCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -98,42 +90,41 @@ internal class InvoiceLineItemCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -143,26 +134,21 @@ internal class InvoiceLineItemCreateResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.builder() + InvoiceLineItemCreateResponse.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Grouping - .builder() + InvoiceLineItemCreateResponse.SubLineItem.Matrix.Grouping.builder() .key("region") .value("west") .build() ) .matrixConfig( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.MatrixConfig - .builder() + InvoiceLineItemCreateResponse.SubLineItem.Matrix.MatrixConfig.builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Type.MATRIX - ) .build() ) .subtotal("9.00") @@ -180,15 +166,9 @@ internal class InvoiceLineItemCreateResponseTest { assertThat(invoiceLineItemCreateResponse.adjustedSubtotal()).isEqualTo("5.00") assertThat(invoiceLineItemCreateResponse.adjustments()) .containsExactly( - InvoiceLineItemCreateResponse.Adjustment.ofMonetaryUsageDiscount( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + InvoiceLineItemCreateResponse.Adjustment.ofUsageDiscount( + InvoiceLineItemCreateResponse.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -236,22 +216,20 @@ internal class InvoiceLineItemCreateResponseTest { assertThat(invoiceLineItemCreateResponse.price()) .contains( Price.ofUnit( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -269,42 +247,41 @@ internal class InvoiceLineItemCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -318,26 +295,21 @@ internal class InvoiceLineItemCreateResponseTest { assertThat(invoiceLineItemCreateResponse.subLineItems()) .containsExactly( InvoiceLineItemCreateResponse.SubLineItem.ofMatrix( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.builder() + InvoiceLineItemCreateResponse.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Grouping - .builder() + InvoiceLineItemCreateResponse.SubLineItem.Matrix.Grouping.builder() .key("region") .value("west") .build() ) .matrixConfig( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.MatrixConfig - .builder() + InvoiceLineItemCreateResponse.SubLineItem.Matrix.MatrixConfig.builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Type.MATRIX - ) .build() ) ) @@ -362,14 +334,8 @@ internal class InvoiceLineItemCreateResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + InvoiceLineItemCreateResponse.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - InvoiceLineItemCreateResponse.Adjustment.MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -408,22 +374,20 @@ internal class InvoiceLineItemCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -441,42 +405,41 @@ internal class InvoiceLineItemCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -486,26 +449,21 @@ internal class InvoiceLineItemCreateResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.builder() + InvoiceLineItemCreateResponse.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Grouping - .builder() + InvoiceLineItemCreateResponse.SubLineItem.Matrix.Grouping.builder() .key("region") .value("west") .build() ) .matrixConfig( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.MatrixConfig - .builder() + InvoiceLineItemCreateResponse.SubLineItem.Matrix.MatrixConfig.builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - InvoiceLineItemCreateResponse.SubLineItem.MatrixSubLineItem.Type.MATRIX - ) .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 a784bdda..d16f28d8 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 @@ -115,15 +115,8 @@ internal class InvoiceListPageResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -162,28 +155,26 @@ internal class InvoiceListPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -203,30 +194,27 @@ internal class InvoiceListPageResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -234,23 +222,22 @@ internal class InvoiceListPageResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -262,28 +249,22 @@ internal class InvoiceListPageResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Grouping - .builder() + Invoice.LineItem.SubLineItem.Matrix.Grouping.builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -452,14 +433,8 @@ internal class InvoiceListPageResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -498,26 +473,25 @@ internal class InvoiceListPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -537,48 +511,44 @@ internal class InvoiceListPageResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -588,26 +558,21 @@ internal class InvoiceListPageResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Grouping - .builder() + Invoice.LineItem.SubLineItem.Matrix.Grouping.builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.MatrixConfig - .builder() + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig.builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type.MATRIX - ) .build() ) .subtotal("9.00") @@ -783,15 +748,8 @@ internal class InvoiceListPageResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -830,28 +788,26 @@ internal class InvoiceListPageResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -871,30 +827,27 @@ internal class InvoiceListPageResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -902,23 +855,22 @@ internal class InvoiceListPageResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -930,28 +882,22 @@ internal class InvoiceListPageResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Grouping - .builder() + Invoice.LineItem.SubLineItem.Matrix.Grouping.builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") 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 7cd2f569..b63e5c5a 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 @@ -105,13 +105,8 @@ internal class InvoiceTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment.builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -150,25 +145,24 @@ internal class InvoiceTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -186,45 +180,43 @@ internal class InvoiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -234,24 +226,21 @@ internal class InvoiceTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Grouping - .builder() + Invoice.LineItem.SubLineItem.Matrix.Grouping.builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.MatrixConfig - .builder() + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig.builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type(Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type.MATRIX) .build() ) .subtotal("9.00") @@ -422,13 +411,8 @@ internal class InvoiceTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment.builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -467,24 +451,22 @@ internal class InvoiceTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -502,44 +484,41 @@ internal class InvoiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -549,23 +528,21 @@ internal class InvoiceTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Grouping.builder() + Invoice.LineItem.SubLineItem.Matrix.Grouping.builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.MatrixConfig - .builder() + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig.builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type(Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type.MATRIX) .build() ) .subtotal("9.00") @@ -737,13 +714,8 @@ internal class InvoiceTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment.builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -782,25 +754,24 @@ internal class InvoiceTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -818,45 +789,43 @@ internal class InvoiceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -866,24 +835,21 @@ internal class InvoiceTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Grouping - .builder() + Invoice.LineItem.SubLineItem.Matrix.Grouping.builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.MatrixConfig - .builder() + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig.builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type(Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type.MATRIX) .build() ) .subtotal("9.00") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt index e6aa9769..59fb40f1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PlanCreateParamsTest.kt @@ -14,24 +14,22 @@ internal class PlanCreateParamsTest { .currency("currency") .name("name") .addPrice( - PlanCreateParams.Price.NewPlanUnitPrice.builder() - .cadence(PlanCreateParams.Price.NewPlanUnitPrice.Cadence.ANNUAL) + PlanCreateParams.Price.Unit.builder() + .cadence(PlanCreateParams.Price.Unit.Cadence.ANNUAL) .itemId("item_id") - .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() + PlanCreateParams.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration.builder() + PlanCreateParams.Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .DurationUnit + PlanCreateParams.Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() @@ -42,18 +40,16 @@ internal class PlanCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .DurationUnit + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) .metadata( - PlanCreateParams.Price.NewPlanUnitPrice.Metadata.builder() + PlanCreateParams.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -78,25 +74,22 @@ internal class PlanCreateParamsTest { .currency("currency") .name("name") .addPrice( - PlanCreateParams.Price.NewPlanUnitPrice.builder() - .cadence(PlanCreateParams.Price.NewPlanUnitPrice.Cadence.ANNUAL) + PlanCreateParams.Price.Unit.builder() + .cadence(PlanCreateParams.Price.Unit.Cadence.ANNUAL) .itemId("item_id") - .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() + PlanCreateParams.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .builder() + PlanCreateParams.Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .BillingCycleConfiguration + PlanCreateParams.Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) @@ -108,19 +101,17 @@ internal class PlanCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .InvoicingCycleConfiguration + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .metadata( - PlanCreateParams.Price.NewPlanUnitPrice.Metadata.builder() + PlanCreateParams.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -143,26 +134,23 @@ internal class PlanCreateParamsTest { assertThat(body.name()).isEqualTo("name") assertThat(body.prices()) .containsExactly( - PlanCreateParams.Price.ofNewPlanUnit( - PlanCreateParams.Price.NewPlanUnitPrice.builder() - .cadence(PlanCreateParams.Price.NewPlanUnitPrice.Cadence.ANNUAL) + PlanCreateParams.Price.ofUnit( + PlanCreateParams.Price.Unit.builder() + .cadence(PlanCreateParams.Price.Unit.Cadence.ANNUAL) .itemId("item_id") - .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() + PlanCreateParams.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .builder() + PlanCreateParams.Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .BillingCycleConfiguration + PlanCreateParams.Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) @@ -174,19 +162,17 @@ internal class PlanCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .InvoicingCycleConfiguration + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .metadata( - PlanCreateParams.Price.NewPlanUnitPrice.Metadata.builder() + PlanCreateParams.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -212,13 +198,12 @@ internal class PlanCreateParamsTest { .currency("currency") .name("name") .addPrice( - PlanCreateParams.Price.NewPlanUnitPrice.builder() - .cadence(PlanCreateParams.Price.NewPlanUnitPrice.Cadence.ANNUAL) + PlanCreateParams.Price.Unit.builder() + .cadence(PlanCreateParams.Price.Unit.Cadence.ANNUAL) .itemId("item_id") - .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() + PlanCreateParams.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) @@ -232,14 +217,13 @@ internal class PlanCreateParamsTest { assertThat(body.name()).isEqualTo("name") assertThat(body.prices()) .containsExactly( - PlanCreateParams.Price.ofNewPlanUnit( - PlanCreateParams.Price.NewPlanUnitPrice.builder() - .cadence(PlanCreateParams.Price.NewPlanUnitPrice.Cadence.ANNUAL) + PlanCreateParams.Price.ofUnit( + PlanCreateParams.Price.Unit.builder() + .cadence(PlanCreateParams.Price.Unit.Cadence.ANNUAL) .itemId("item_id") - .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() + PlanCreateParams.Price.Unit.UnitConfig.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 b10f75a9..eeff4d3d 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 @@ -19,12 +19,8 @@ internal class PlanListPageResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -110,25 +106,24 @@ internal class PlanListPageResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -146,45 +141,43 @@ internal class PlanListPageResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -218,12 +211,8 @@ internal class PlanListPageResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -309,24 +298,22 @@ internal class PlanListPageResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -344,44 +331,41 @@ internal class PlanListPageResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -418,12 +402,8 @@ internal class PlanListPageResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -509,25 +489,24 @@ internal class PlanListPageResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -545,45 +524,43 @@ internal class PlanListPageResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() 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 75426179..af5d68f7 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 @@ -18,12 +18,8 @@ internal class PlanTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -109,22 +105,20 @@ internal class PlanTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -142,42 +136,41 @@ internal class PlanTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -204,13 +197,9 @@ internal class PlanTest { assertThat(plan.id()).isEqualTo("id") assertThat(plan.adjustments()) .containsExactly( - Plan.Adjustment.ofPlanPhaseUsageDiscount( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.ofUsageDiscount( + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -307,22 +296,20 @@ internal class PlanTest { assertThat(plan.prices()) .containsExactly( Price.ofUnit( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -340,42 +327,41 @@ internal class PlanTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -409,12 +395,8 @@ internal class PlanTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -500,22 +482,20 @@ internal class PlanTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -533,42 +513,41 @@ internal class PlanTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt index 2d960c9c..a450e816 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/PriceCreateParamsTest.kt @@ -12,27 +12,23 @@ internal class PriceCreateParamsTest { fun create() { PriceCreateParams.builder() .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + PriceCreateParams.Body.Unit.builder() + .cadence(PriceCreateParams.Body.Unit.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() + PriceCreateParams.Body.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.BillingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .DurationUnit + PriceCreateParams.Body.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() @@ -42,19 +38,16 @@ internal class PriceCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.InvoicingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .DurationUnit + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + PriceCreateParams.Body.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -68,26 +61,23 @@ internal class PriceCreateParamsTest { val params = PriceCreateParams.builder() .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + PriceCreateParams.Body.Unit.builder() + .cadence(PriceCreateParams.Body.Unit.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() + PriceCreateParams.Body.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.BillingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration + PriceCreateParams.Body.Unit.BillingCycleConfiguration .DurationUnit .DAY ) @@ -98,19 +88,17 @@ internal class PriceCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.InvoicingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + PriceCreateParams.Body.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -122,27 +110,24 @@ internal class PriceCreateParamsTest { assertThat(body) .isEqualTo( - PriceCreateParams.Body.ofNewFloatingUnitPrice( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + PriceCreateParams.Body.ofUnit( + PriceCreateParams.Body.Unit.builder() + .cadence(PriceCreateParams.Body.Unit.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() + PriceCreateParams.Body.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.BillingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration + PriceCreateParams.Body.Unit.BillingCycleConfiguration .DurationUnit .DAY ) @@ -153,19 +138,17 @@ internal class PriceCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice.InvoicingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + PriceCreateParams.Body.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -179,14 +162,13 @@ internal class PriceCreateParamsTest { val params = PriceCreateParams.builder() .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + PriceCreateParams.Body.Unit.builder() + .cadence(PriceCreateParams.Body.Unit.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() + PriceCreateParams.Body.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) @@ -198,15 +180,14 @@ internal class PriceCreateParamsTest { assertThat(body) .isEqualTo( - PriceCreateParams.Body.ofNewFloatingUnitPrice( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + PriceCreateParams.Body.ofUnit( + PriceCreateParams.Body.Unit.builder() + .cadence(PriceCreateParams.Body.Unit.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() + PriceCreateParams.Body.Unit.UnitConfig.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 ce5171b1..53776c4a 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 @@ -16,22 +16,20 @@ internal class PriceListPageResponseTest { val priceListPageResponse = PriceListPageResponse.builder() .addData( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -49,42 +47,41 @@ internal class PriceListPageResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -99,22 +96,20 @@ internal class PriceListPageResponseTest { assertThat(priceListPageResponse.data()) .containsExactly( Price.ofUnit( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -132,42 +127,41 @@ internal class PriceListPageResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -185,22 +179,20 @@ internal class PriceListPageResponseTest { val priceListPageResponse = PriceListPageResponse.builder() .addData( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -218,42 +210,41 @@ internal class PriceListPageResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .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 3d2e7872..730357de 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 @@ -18,20 +18,20 @@ internal class PriceTest { @Test fun ofUnit() { val unit = - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -49,38 +49,37 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig(Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build()) + .priceType(Price.Unit.PriceType.USAGE_PRICE) + .unitConfig(Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -90,7 +89,7 @@ internal class PriceTest { val price = Price.ofUnit(unit) assertThat(price.unit()).contains(unit) - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -124,22 +123,20 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofUnit( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric(Price.UnitPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -157,42 +154,37 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) - .unitConfig( - Price.UnitPrice.UnitConfig.builder().unitAmount("unit_amount").build() - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) + .unitConfig(Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build()) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -207,22 +199,22 @@ internal class PriceTest { } @Test - fun ofPackagePrice() { - val packagePrice = - Price.PackagePrice.builder() + fun ofPackage() { + val package_ = + Price.Package.builder() .id("id") - .billableMetric(Price.PackagePrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Package.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.PackagePrice.BillingCycleConfiguration.builder() + Price.Package.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.PackagePrice.BillingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Package.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.PackagePrice.Cadence.ONE_TIME) + .cadence(Price.Package.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.PackagePrice.CreditAllocation.builder() + Price.Package.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -240,55 +232,52 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.PackagePrice.InvoicingCycleConfiguration.builder() + Price.Package.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.PackagePrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Package.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.PackagePrice.Item.builder().id("id").name("name").build()) + .item(Price.Package.Item.builder().id("id").name("name").build()) .maximum( - Price.PackagePrice.Maximum.builder() + Price.Package.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.PackagePrice.Metadata.builder() + Price.Package.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.PackagePrice.Minimum.builder() + Price.Package.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.PackagePrice.ModelType.PACKAGE) .name("name") .packageConfig( - Price.PackagePrice.PackageConfig.builder() + Price.Package.PackageConfig.builder() .packageAmount("package_amount") .packageSize(0L) .build() ) .planPhaseOrder(0L) - .priceType(Price.PackagePrice.PriceType.USAGE_PRICE) + .priceType(Price.Package.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.PackagePrice.DimensionalPriceConfiguration.builder() + Price.Package.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() ) .build() - val price = Price.ofPackagePrice(packagePrice) + val price = Price.ofPackage(package_) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).contains(packagePrice) + assertThat(price.package_()).contains(package_) assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -318,26 +307,24 @@ internal class PriceTest { } @Test - fun ofPackagePriceRoundtrip() { + fun ofPackageRoundtrip() { val jsonMapper = jsonMapper() val price = - Price.ofPackagePrice( - Price.PackagePrice.builder() + Price.ofPackage( + Price.Package.builder() .id("id") - .billableMetric(Price.PackagePrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Package.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.PackagePrice.BillingCycleConfiguration.builder() + Price.Package.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.PackagePrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Package.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.PackagePrice.Cadence.ONE_TIME) + .cadence(Price.Package.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.PackagePrice.CreditAllocation.builder() + Price.Package.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -355,45 +342,44 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.PackagePrice.InvoicingCycleConfiguration.builder() + Price.Package.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.PackagePrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Package.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.PackagePrice.Item.builder().id("id").name("name").build()) + .item(Price.Package.Item.builder().id("id").name("name").build()) .maximum( - Price.PackagePrice.Maximum.builder() + Price.Package.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.PackagePrice.Metadata.builder() + Price.Package.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.PackagePrice.Minimum.builder() + Price.Package.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.PackagePrice.ModelType.PACKAGE) .name("name") .packageConfig( - Price.PackagePrice.PackageConfig.builder() + Price.Package.PackageConfig.builder() .packageAmount("package_amount") .packageSize(0L) .build() ) .planPhaseOrder(0L) - .priceType(Price.PackagePrice.PriceType.USAGE_PRICE) + .priceType(Price.Package.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.PackagePrice.DimensionalPriceConfiguration.builder() + Price.Package.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -410,20 +396,20 @@ internal class PriceTest { @Test fun ofMatrix() { val matrix = - Price.MatrixPrice.builder() + Price.Matrix.builder() .id("id") - .billableMetric(Price.MatrixPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Matrix.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.MatrixPrice.BillingCycleConfiguration.builder() + Price.Matrix.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.MatrixPrice.BillingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Matrix.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MatrixPrice.Cadence.ONE_TIME) + .cadence(Price.Matrix.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.MatrixPrice.CreditAllocation.builder() + Price.Matrix.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -441,20 +427,18 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.MatrixPrice.InvoicingCycleConfiguration.builder() + Price.Matrix.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.MatrixPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Matrix.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.MatrixPrice.Item.builder().id("id").name("name").build()) + .item(Price.Matrix.Item.builder().id("id").name("name").build()) .matrixConfig( - Price.MatrixPrice.MatrixConfig.builder() + Price.Matrix.MatrixConfig.builder() .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - Price.MatrixPrice.MatrixConfig.MatrixValue.builder() + Price.Matrix.MatrixConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -462,30 +446,29 @@ internal class PriceTest { .build() ) .maximum( - Price.MatrixPrice.Maximum.builder() + Price.Matrix.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixPrice.Metadata.builder() + Price.Matrix.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.MatrixPrice.Minimum.builder() + Price.Matrix.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.MatrixPrice.ModelType.MATRIX) .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixPrice.PriceType.USAGE_PRICE) + .priceType(Price.Matrix.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.MatrixPrice.DimensionalPriceConfiguration.builder() + Price.Matrix.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -495,7 +478,7 @@ internal class PriceTest { val price = Price.ofMatrix(matrix) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).contains(matrix) assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -529,22 +512,20 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofMatrix( - Price.MatrixPrice.builder() + Price.Matrix.builder() .id("id") - .billableMetric(Price.MatrixPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Matrix.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.MatrixPrice.BillingCycleConfiguration.builder() + Price.Matrix.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.MatrixPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Matrix.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.MatrixPrice.Cadence.ONE_TIME) + .cadence(Price.Matrix.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.MatrixPrice.CreditAllocation.builder() + Price.Matrix.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -562,20 +543,18 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.MatrixPrice.InvoicingCycleConfiguration.builder() + Price.Matrix.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.MatrixPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Matrix.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.MatrixPrice.Item.builder().id("id").name("name").build()) + .item(Price.Matrix.Item.builder().id("id").name("name").build()) .matrixConfig( - Price.MatrixPrice.MatrixConfig.builder() + Price.Matrix.MatrixConfig.builder() .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - Price.MatrixPrice.MatrixConfig.MatrixValue.builder() + Price.Matrix.MatrixConfig.MatrixValue.builder() .addDimensionValue("string") .unitAmount("unit_amount") .build() @@ -583,30 +562,29 @@ internal class PriceTest { .build() ) .maximum( - Price.MatrixPrice.Maximum.builder() + Price.Matrix.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixPrice.Metadata.builder() + Price.Matrix.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.MatrixPrice.Minimum.builder() + Price.Matrix.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.MatrixPrice.ModelType.MATRIX) .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixPrice.PriceType.USAGE_PRICE) + .priceType(Price.Matrix.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.MatrixPrice.DimensionalPriceConfiguration.builder() + Price.Matrix.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -623,20 +601,20 @@ internal class PriceTest { @Test fun ofTiered() { val tiered = - Price.TieredPrice.builder() + Price.Tiered.builder() .id("id") - .billableMetric(Price.TieredPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Tiered.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.TieredPrice.BillingCycleConfiguration.builder() + Price.Tiered.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.TieredPrice.BillingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Tiered.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredPrice.Cadence.ONE_TIME) + .cadence(Price.Tiered.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredPrice.CreditAllocation.builder() + Price.Tiered.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -654,41 +632,38 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredPrice.InvoicingCycleConfiguration.builder() + Price.Tiered.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.TieredPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Tiered.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.TieredPrice.Item.builder().id("id").name("name").build()) + .item(Price.Tiered.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredPrice.Maximum.builder() + Price.Tiered.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPrice.Metadata.builder() + Price.Tiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredPrice.Minimum.builder() + Price.Tiered.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredPrice.ModelType.TIERED) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPrice.PriceType.USAGE_PRICE) + .priceType(Price.Tiered.PriceType.USAGE_PRICE) .tieredConfig( - Price.TieredPrice.TieredConfig.builder() + Price.Tiered.TieredConfig.builder() .addTier( - Price.TieredPrice.TieredConfig.Tier.builder() + Price.Tiered.TieredConfig.Tier.builder() .firstUnit(0.0) .unitAmount("unit_amount") .lastUnit(0.0) @@ -697,7 +672,7 @@ internal class PriceTest { .build() ) .dimensionalPriceConfiguration( - Price.TieredPrice.DimensionalPriceConfiguration.builder() + Price.Tiered.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -707,7 +682,7 @@ internal class PriceTest { val price = Price.ofTiered(tiered) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).contains(tiered) assertThat(price.tieredBps()).isEmpty @@ -741,22 +716,20 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofTiered( - Price.TieredPrice.builder() + Price.Tiered.builder() .id("id") - .billableMetric(Price.TieredPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Tiered.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.TieredPrice.BillingCycleConfiguration.builder() + Price.Tiered.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.TieredPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Tiered.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredPrice.Cadence.ONE_TIME) + .cadence(Price.Tiered.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredPrice.CreditAllocation.builder() + Price.Tiered.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -774,41 +747,38 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredPrice.InvoicingCycleConfiguration.builder() + Price.Tiered.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.TieredPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Tiered.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.TieredPrice.Item.builder().id("id").name("name").build()) + .item(Price.Tiered.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredPrice.Maximum.builder() + Price.Tiered.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPrice.Metadata.builder() + Price.Tiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredPrice.Minimum.builder() + Price.Tiered.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredPrice.ModelType.TIERED) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPrice.PriceType.USAGE_PRICE) + .priceType(Price.Tiered.PriceType.USAGE_PRICE) .tieredConfig( - Price.TieredPrice.TieredConfig.builder() + Price.Tiered.TieredConfig.builder() .addTier( - Price.TieredPrice.TieredConfig.Tier.builder() + Price.Tiered.TieredConfig.Tier.builder() .firstUnit(0.0) .unitAmount("unit_amount") .lastUnit(0.0) @@ -817,7 +787,7 @@ internal class PriceTest { .build() ) .dimensionalPriceConfiguration( - Price.TieredPrice.DimensionalPriceConfiguration.builder() + Price.Tiered.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -834,22 +804,20 @@ internal class PriceTest { @Test fun ofTieredBps() { val tieredBps = - Price.TieredBpsPrice.builder() + Price.TieredBps.builder() .id("id") - .billableMetric(Price.TieredBpsPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.TieredBps.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.TieredBpsPrice.BillingCycleConfiguration.builder() + Price.TieredBps.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.TieredBpsPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.TieredBps.BillingCycleConfiguration.DurationUnit.DAY) .build() ) - .cadence(Price.TieredBpsPrice.Cadence.ONE_TIME) + .cadence(Price.TieredBps.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredBpsPrice.CreditAllocation.builder() + Price.TieredBps.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -867,41 +835,38 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredBpsPrice.InvoicingCycleConfiguration.builder() + Price.TieredBps.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.TieredBpsPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.TieredBps.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.TieredBpsPrice.Item.builder().id("id").name("name").build()) + .item(Price.TieredBps.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredBpsPrice.Maximum.builder() + Price.TieredBps.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredBpsPrice.Metadata.builder() + Price.TieredBps.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredBpsPrice.Minimum.builder() + Price.TieredBps.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredBpsPrice.ModelType.TIERED_BPS) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredBpsPrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredBps.PriceType.USAGE_PRICE) .tieredBpsConfig( - Price.TieredBpsPrice.TieredBpsConfig.builder() + Price.TieredBps.TieredBpsConfig.builder() .addTier( - Price.TieredBpsPrice.TieredBpsConfig.Tier.builder() + Price.TieredBps.TieredBpsConfig.Tier.builder() .bps(0.0) .minimumAmount("minimum_amount") .maximumAmount("maximum_amount") @@ -911,7 +876,7 @@ internal class PriceTest { .build() ) .dimensionalPriceConfiguration( - Price.TieredBpsPrice.DimensionalPriceConfiguration.builder() + Price.TieredBps.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -921,7 +886,7 @@ internal class PriceTest { val price = Price.ofTieredBps(tieredBps) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).contains(tieredBps) @@ -955,22 +920,22 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofTieredBps( - Price.TieredBpsPrice.builder() + Price.TieredBps.builder() .id("id") - .billableMetric(Price.TieredBpsPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.TieredBps.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.TieredBpsPrice.BillingCycleConfiguration.builder() + Price.TieredBps.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredBpsPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.TieredBps.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.TieredBpsPrice.Cadence.ONE_TIME) + .cadence(Price.TieredBps.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredBpsPrice.CreditAllocation.builder() + Price.TieredBps.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -988,41 +953,40 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredBpsPrice.InvoicingCycleConfiguration.builder() + Price.TieredBps.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredBpsPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.TieredBps.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.TieredBpsPrice.Item.builder().id("id").name("name").build()) + .item(Price.TieredBps.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredBpsPrice.Maximum.builder() + Price.TieredBps.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredBpsPrice.Metadata.builder() + Price.TieredBps.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredBpsPrice.Minimum.builder() + Price.TieredBps.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredBpsPrice.ModelType.TIERED_BPS) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredBpsPrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredBps.PriceType.USAGE_PRICE) .tieredBpsConfig( - Price.TieredBpsPrice.TieredBpsConfig.builder() + Price.TieredBps.TieredBpsConfig.builder() .addTier( - Price.TieredBpsPrice.TieredBpsConfig.Tier.builder() + Price.TieredBps.TieredBpsConfig.Tier.builder() .bps(0.0) .minimumAmount("minimum_amount") .maximumAmount("maximum_amount") @@ -1032,7 +996,7 @@ internal class PriceTest { .build() ) .dimensionalPriceConfiguration( - Price.TieredBpsPrice.DimensionalPriceConfiguration.builder() + Price.TieredBps.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1049,26 +1013,26 @@ internal class PriceTest { @Test fun ofBps() { val bps = - Price.BpsPrice.builder() + Price.Bps.builder() .id("id") - .billableMetric(Price.BpsPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Bps.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.BpsPrice.BillingCycleConfiguration.builder() + Price.Bps.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.BpsPrice.BillingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Bps.BillingCycleConfiguration.DurationUnit.DAY) .build() ) .bpsConfig( - Price.BpsPrice.BpsConfig.builder() + Price.Bps.BpsConfig.builder() .bps(0.0) .perUnitMaximum("per_unit_maximum") .build() ) - .cadence(Price.BpsPrice.Cadence.ONE_TIME) + .cadence(Price.Bps.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.BpsPrice.CreditAllocation.builder() + Price.Bps.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1086,37 +1050,36 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.BpsPrice.InvoicingCycleConfiguration.builder() + Price.Bps.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.BpsPrice.InvoicingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Bps.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.BpsPrice.Item.builder().id("id").name("name").build()) + .item(Price.Bps.Item.builder().id("id").name("name").build()) .maximum( - Price.BpsPrice.Maximum.builder() + Price.Bps.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.BpsPrice.Metadata.builder() + Price.Bps.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.BpsPrice.Minimum.builder() + Price.Bps.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.BpsPrice.ModelType.BPS) .name("name") .planPhaseOrder(0L) - .priceType(Price.BpsPrice.PriceType.USAGE_PRICE) + .priceType(Price.Bps.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.BpsPrice.DimensionalPriceConfiguration.builder() + Price.Bps.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1126,7 +1089,7 @@ internal class PriceTest { val price = Price.ofBps(bps) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -1160,26 +1123,26 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofBps( - Price.BpsPrice.builder() + Price.Bps.builder() .id("id") - .billableMetric(Price.BpsPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Bps.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.BpsPrice.BillingCycleConfiguration.builder() + Price.Bps.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.BpsPrice.BillingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Bps.BillingCycleConfiguration.DurationUnit.DAY) .build() ) .bpsConfig( - Price.BpsPrice.BpsConfig.builder() + Price.Bps.BpsConfig.builder() .bps(0.0) .perUnitMaximum("per_unit_maximum") .build() ) - .cadence(Price.BpsPrice.Cadence.ONE_TIME) + .cadence(Price.Bps.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.BpsPrice.CreditAllocation.builder() + Price.Bps.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1197,39 +1160,36 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.BpsPrice.InvoicingCycleConfiguration.builder() + Price.Bps.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.BpsPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Bps.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.BpsPrice.Item.builder().id("id").name("name").build()) + .item(Price.Bps.Item.builder().id("id").name("name").build()) .maximum( - Price.BpsPrice.Maximum.builder() + Price.Bps.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.BpsPrice.Metadata.builder() + Price.Bps.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.BpsPrice.Minimum.builder() + Price.Bps.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.BpsPrice.ModelType.BPS) .name("name") .planPhaseOrder(0L) - .priceType(Price.BpsPrice.PriceType.USAGE_PRICE) + .priceType(Price.Bps.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.BpsPrice.DimensionalPriceConfiguration.builder() + Price.Bps.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1246,19 +1206,19 @@ internal class PriceTest { @Test fun ofBulkBps() { val bulkBps = - Price.BulkBpsPrice.builder() + Price.BulkBps.builder() .id("id") - .billableMetric(Price.BulkBpsPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.BulkBps.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.BulkBpsPrice.BillingCycleConfiguration.builder() + Price.BulkBps.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.BulkBpsPrice.BillingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.BulkBps.BillingCycleConfiguration.DurationUnit.DAY) .build() ) .bulkBpsConfig( - Price.BulkBpsPrice.BulkBpsConfig.builder() + Price.BulkBps.BulkBpsConfig.builder() .addTier( - Price.BulkBpsPrice.BulkBpsConfig.Tier.builder() + Price.BulkBps.BulkBpsConfig.Tier.builder() .bps(0.0) .maximumAmount("maximum_amount") .perUnitMaximum("per_unit_maximum") @@ -1266,11 +1226,11 @@ internal class PriceTest { ) .build() ) - .cadence(Price.BulkBpsPrice.Cadence.ONE_TIME) + .cadence(Price.BulkBps.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.BulkBpsPrice.CreditAllocation.builder() + Price.BulkBps.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1288,39 +1248,36 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.BulkBpsPrice.InvoicingCycleConfiguration.builder() + Price.BulkBps.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.BulkBpsPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.BulkBps.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.BulkBpsPrice.Item.builder().id("id").name("name").build()) + .item(Price.BulkBps.Item.builder().id("id").name("name").build()) .maximum( - Price.BulkBpsPrice.Maximum.builder() + Price.BulkBps.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.BulkBpsPrice.Metadata.builder() + Price.BulkBps.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.BulkBpsPrice.Minimum.builder() + Price.BulkBps.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.BulkBpsPrice.ModelType.BULK_BPS) .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkBpsPrice.PriceType.USAGE_PRICE) + .priceType(Price.BulkBps.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.BulkBpsPrice.DimensionalPriceConfiguration.builder() + Price.BulkBps.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1330,7 +1287,7 @@ internal class PriceTest { val price = Price.ofBulkBps(bulkBps) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -1364,21 +1321,19 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofBulkBps( - Price.BulkBpsPrice.builder() + Price.BulkBps.builder() .id("id") - .billableMetric(Price.BulkBpsPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.BulkBps.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.BulkBpsPrice.BillingCycleConfiguration.builder() + Price.BulkBps.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.BulkBpsPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.BulkBps.BillingCycleConfiguration.DurationUnit.DAY) .build() ) .bulkBpsConfig( - Price.BulkBpsPrice.BulkBpsConfig.builder() + Price.BulkBps.BulkBpsConfig.builder() .addTier( - Price.BulkBpsPrice.BulkBpsConfig.Tier.builder() + Price.BulkBps.BulkBpsConfig.Tier.builder() .bps(0.0) .maximumAmount("maximum_amount") .perUnitMaximum("per_unit_maximum") @@ -1386,11 +1341,11 @@ internal class PriceTest { ) .build() ) - .cadence(Price.BulkBpsPrice.Cadence.ONE_TIME) + .cadence(Price.BulkBps.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.BulkBpsPrice.CreditAllocation.builder() + Price.BulkBps.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1408,39 +1363,38 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.BulkBpsPrice.InvoicingCycleConfiguration.builder() + Price.BulkBps.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.BulkBpsPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.BulkBps.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.BulkBpsPrice.Item.builder().id("id").name("name").build()) + .item(Price.BulkBps.Item.builder().id("id").name("name").build()) .maximum( - Price.BulkBpsPrice.Maximum.builder() + Price.BulkBps.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.BulkBpsPrice.Metadata.builder() + Price.BulkBps.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.BulkBpsPrice.Minimum.builder() + Price.BulkBps.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.BulkBpsPrice.ModelType.BULK_BPS) .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkBpsPrice.PriceType.USAGE_PRICE) + .priceType(Price.BulkBps.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.BulkBpsPrice.DimensionalPriceConfiguration.builder() + Price.BulkBps.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1457,30 +1411,30 @@ internal class PriceTest { @Test fun ofBulk() { val bulk = - Price.BulkPrice.builder() + Price.Bulk.builder() .id("id") - .billableMetric(Price.BulkPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Bulk.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.BulkPrice.BillingCycleConfiguration.builder() + Price.Bulk.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.BulkPrice.BillingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Bulk.BillingCycleConfiguration.DurationUnit.DAY) .build() ) .bulkConfig( - Price.BulkPrice.BulkConfig.builder() + Price.Bulk.BulkConfig.builder() .addTier( - Price.BulkPrice.BulkConfig.Tier.builder() + Price.Bulk.BulkConfig.Tier.builder() .unitAmount("unit_amount") .maximumUnits(0.0) .build() ) .build() ) - .cadence(Price.BulkPrice.Cadence.ONE_TIME) + .cadence(Price.Bulk.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.BulkPrice.CreditAllocation.builder() + Price.Bulk.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1498,37 +1452,36 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.BulkPrice.InvoicingCycleConfiguration.builder() + Price.Bulk.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit(Price.BulkPrice.InvoicingCycleConfiguration.DurationUnit.DAY) + .durationUnit(Price.Bulk.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.BulkPrice.Item.builder().id("id").name("name").build()) + .item(Price.Bulk.Item.builder().id("id").name("name").build()) .maximum( - Price.BulkPrice.Maximum.builder() + Price.Bulk.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.BulkPrice.Metadata.builder() + Price.Bulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.BulkPrice.Minimum.builder() + Price.Bulk.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.BulkPrice.ModelType.BULK) .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkPrice.PriceType.USAGE_PRICE) + .priceType(Price.Bulk.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.BulkPrice.DimensionalPriceConfiguration.builder() + Price.Bulk.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1538,7 +1491,7 @@ internal class PriceTest { val price = Price.ofBulk(bulk) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -1572,32 +1525,30 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofBulk( - Price.BulkPrice.builder() + Price.Bulk.builder() .id("id") - .billableMetric(Price.BulkPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.Bulk.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.BulkPrice.BillingCycleConfiguration.builder() + Price.Bulk.BillingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.BulkPrice.BillingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Bulk.BillingCycleConfiguration.DurationUnit.DAY) .build() ) .bulkConfig( - Price.BulkPrice.BulkConfig.builder() + Price.Bulk.BulkConfig.builder() .addTier( - Price.BulkPrice.BulkConfig.Tier.builder() + Price.Bulk.BulkConfig.Tier.builder() .unitAmount("unit_amount") .maximumUnits(0.0) .build() ) .build() ) - .cadence(Price.BulkPrice.Cadence.ONE_TIME) + .cadence(Price.Bulk.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.BulkPrice.CreditAllocation.builder() + Price.Bulk.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1615,39 +1566,36 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.BulkPrice.InvoicingCycleConfiguration.builder() + Price.Bulk.InvoicingCycleConfiguration.builder() .duration(0L) - .durationUnit( - Price.BulkPrice.InvoicingCycleConfiguration.DurationUnit.DAY - ) + .durationUnit(Price.Bulk.InvoicingCycleConfiguration.DurationUnit.DAY) .build() ) - .item(Price.BulkPrice.Item.builder().id("id").name("name").build()) + .item(Price.Bulk.Item.builder().id("id").name("name").build()) .maximum( - Price.BulkPrice.Maximum.builder() + Price.Bulk.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.BulkPrice.Metadata.builder() + Price.Bulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.BulkPrice.Minimum.builder() + Price.Bulk.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.BulkPrice.ModelType.BULK) .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkPrice.PriceType.USAGE_PRICE) + .priceType(Price.Bulk.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.BulkPrice.DimensionalPriceConfiguration.builder() + Price.Bulk.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1664,25 +1612,24 @@ internal class PriceTest { @Test fun ofThresholdTotalAmount() { val thresholdTotalAmount = - Price.ThresholdTotalAmountPrice.builder() + Price.ThresholdTotalAmount.builder() .id("id") .billableMetric( - Price.ThresholdTotalAmountPrice.BillableMetric.builder().id("id").build() + Price.ThresholdTotalAmount.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.ThresholdTotalAmountPrice.BillingCycleConfiguration.builder() + Price.ThresholdTotalAmount.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ThresholdTotalAmountPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.ThresholdTotalAmount.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.ThresholdTotalAmountPrice.Cadence.ONE_TIME) + .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.ThresholdTotalAmountPrice.CreditAllocation.builder() + Price.ThresholdTotalAmount.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1700,45 +1647,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.ThresholdTotalAmountPrice.InvoicingCycleConfiguration.builder() + Price.ThresholdTotalAmount.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ThresholdTotalAmountPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.ThresholdTotalAmount.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.ThresholdTotalAmountPrice.Item.builder().id("id").name("name").build()) + .item(Price.ThresholdTotalAmount.Item.builder().id("id").name("name").build()) .maximum( - Price.ThresholdTotalAmountPrice.Maximum.builder() + Price.ThresholdTotalAmount.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.ThresholdTotalAmountPrice.Metadata.builder() + Price.ThresholdTotalAmount.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.ThresholdTotalAmountPrice.Minimum.builder() + Price.ThresholdTotalAmount.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.ThresholdTotalAmountPrice.ModelType.THRESHOLD_TOTAL_AMOUNT) .name("name") .planPhaseOrder(0L) - .priceType(Price.ThresholdTotalAmountPrice.PriceType.USAGE_PRICE) + .priceType(Price.ThresholdTotalAmount.PriceType.USAGE_PRICE) .thresholdTotalAmountConfig( - Price.ThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() + Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.ThresholdTotalAmountPrice.DimensionalPriceConfiguration.builder() + Price.ThresholdTotalAmount.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1748,7 +1693,7 @@ internal class PriceTest { val price = Price.ofThresholdTotalAmount(thresholdTotalAmount) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -1782,26 +1727,25 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofThresholdTotalAmount( - Price.ThresholdTotalAmountPrice.builder() + Price.ThresholdTotalAmount.builder() .id("id") .billableMetric( - Price.ThresholdTotalAmountPrice.BillableMetric.builder().id("id").build() + Price.ThresholdTotalAmount.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.ThresholdTotalAmountPrice.BillingCycleConfiguration.builder() + Price.ThresholdTotalAmount.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ThresholdTotalAmountPrice.BillingCycleConfiguration - .DurationUnit + Price.ThresholdTotalAmount.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.ThresholdTotalAmountPrice.Cadence.ONE_TIME) + .cadence(Price.ThresholdTotalAmount.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.ThresholdTotalAmountPrice.CreditAllocation.builder() + Price.ThresholdTotalAmount.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1819,48 +1763,44 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.ThresholdTotalAmountPrice.InvoicingCycleConfiguration.builder() + Price.ThresholdTotalAmount.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ThresholdTotalAmountPrice.InvoicingCycleConfiguration - .DurationUnit + Price.ThresholdTotalAmount.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.ThresholdTotalAmountPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.ThresholdTotalAmount.Item.builder().id("id").name("name").build()) .maximum( - Price.ThresholdTotalAmountPrice.Maximum.builder() + Price.ThresholdTotalAmount.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.ThresholdTotalAmountPrice.Metadata.builder() + Price.ThresholdTotalAmount.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.ThresholdTotalAmountPrice.Minimum.builder() + Price.ThresholdTotalAmount.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.ThresholdTotalAmountPrice.ModelType.THRESHOLD_TOTAL_AMOUNT) .name("name") .planPhaseOrder(0L) - .priceType(Price.ThresholdTotalAmountPrice.PriceType.USAGE_PRICE) + .priceType(Price.ThresholdTotalAmount.PriceType.USAGE_PRICE) .thresholdTotalAmountConfig( - Price.ThresholdTotalAmountPrice.ThresholdTotalAmountConfig.builder() + Price.ThresholdTotalAmount.ThresholdTotalAmountConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.ThresholdTotalAmountPrice.DimensionalPriceConfiguration.builder() + Price.ThresholdTotalAmount.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1877,22 +1817,22 @@ internal class PriceTest { @Test fun ofTieredPackage() { val tieredPackage = - Price.TieredPackagePrice.builder() + Price.TieredPackage.builder() .id("id") - .billableMetric(Price.TieredPackagePrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.TieredPackage.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.TieredPackagePrice.BillingCycleConfiguration.builder() + Price.TieredPackage.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredPackagePrice.BillingCycleConfiguration.DurationUnit.DAY + Price.TieredPackage.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.TieredPackagePrice.Cadence.ONE_TIME) + .cadence(Price.TieredPackage.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredPackagePrice.CreditAllocation.builder() + Price.TieredPackage.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1910,44 +1850,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredPackagePrice.InvoicingCycleConfiguration.builder() + Price.TieredPackage.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredPackagePrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.TieredPackage.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.TieredPackagePrice.Item.builder().id("id").name("name").build()) + .item(Price.TieredPackage.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredPackagePrice.Maximum.builder() + Price.TieredPackage.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackagePrice.Metadata.builder() + Price.TieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredPackagePrice.Minimum.builder() + Price.TieredPackage.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredPackagePrice.ModelType.TIERED_PACKAGE) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPackagePrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredPackage.PriceType.USAGE_PRICE) .tieredPackageConfig( - Price.TieredPackagePrice.TieredPackageConfig.builder() + Price.TieredPackage.TieredPackageConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.TieredPackagePrice.DimensionalPriceConfiguration.builder() + Price.TieredPackage.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1957,7 +1896,7 @@ internal class PriceTest { val price = Price.ofTieredPackage(tieredPackage) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -1991,24 +1930,22 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofTieredPackage( - Price.TieredPackagePrice.builder() + Price.TieredPackage.builder() .id("id") - .billableMetric( - Price.TieredPackagePrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.TieredPackage.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.TieredPackagePrice.BillingCycleConfiguration.builder() + Price.TieredPackage.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredPackagePrice.BillingCycleConfiguration.DurationUnit.DAY + Price.TieredPackage.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.TieredPackagePrice.Cadence.ONE_TIME) + .cadence(Price.TieredPackage.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredPackagePrice.CreditAllocation.builder() + Price.TieredPackage.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2026,45 +1963,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredPackagePrice.InvoicingCycleConfiguration.builder() + Price.TieredPackage.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredPackagePrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.TieredPackage.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.TieredPackagePrice.Item.builder().id("id").name("name").build()) + .item(Price.TieredPackage.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredPackagePrice.Maximum.builder() + Price.TieredPackage.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackagePrice.Metadata.builder() + Price.TieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredPackagePrice.Minimum.builder() + Price.TieredPackage.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredPackagePrice.ModelType.TIERED_PACKAGE) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPackagePrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredPackage.PriceType.USAGE_PRICE) .tieredPackageConfig( - Price.TieredPackagePrice.TieredPackageConfig.builder() + Price.TieredPackage.TieredPackageConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.TieredPackagePrice.DimensionalPriceConfiguration.builder() + Price.TieredPackage.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2081,22 +2016,22 @@ internal class PriceTest { @Test fun ofGroupedTiered() { val groupedTiered = - Price.GroupedTieredPrice.builder() + Price.GroupedTiered.builder() .id("id") - .billableMetric(Price.GroupedTieredPrice.BillableMetric.builder().id("id").build()) + .billableMetric(Price.GroupedTiered.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.GroupedTieredPrice.BillingCycleConfiguration.builder() + Price.GroupedTiered.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedTieredPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.GroupedTiered.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.GroupedTieredPrice.Cadence.ONE_TIME) + .cadence(Price.GroupedTiered.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedTieredPrice.CreditAllocation.builder() + Price.GroupedTiered.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2114,44 +2049,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedTieredConfig( - Price.GroupedTieredPrice.GroupedTieredConfig.builder() + Price.GroupedTiered.GroupedTieredConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedTieredPrice.InvoicingCycleConfiguration.builder() + Price.GroupedTiered.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedTieredPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.GroupedTiered.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.GroupedTieredPrice.Item.builder().id("id").name("name").build()) + .item(Price.GroupedTiered.Item.builder().id("id").name("name").build()) .maximum( - Price.GroupedTieredPrice.Maximum.builder() + Price.GroupedTiered.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPrice.Metadata.builder() + Price.GroupedTiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedTieredPrice.Minimum.builder() + Price.GroupedTiered.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.GroupedTieredPrice.ModelType.GROUPED_TIERED) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedTieredPrice.DimensionalPriceConfiguration.builder() + Price.GroupedTiered.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2161,7 +2095,7 @@ internal class PriceTest { val price = Price.ofGroupedTiered(groupedTiered) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -2195,24 +2129,22 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofGroupedTiered( - Price.GroupedTieredPrice.builder() + Price.GroupedTiered.builder() .id("id") - .billableMetric( - Price.GroupedTieredPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.GroupedTiered.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.GroupedTieredPrice.BillingCycleConfiguration.builder() + Price.GroupedTiered.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedTieredPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.GroupedTiered.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.GroupedTieredPrice.Cadence.ONE_TIME) + .cadence(Price.GroupedTiered.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedTieredPrice.CreditAllocation.builder() + Price.GroupedTiered.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2230,45 +2162,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedTieredConfig( - Price.GroupedTieredPrice.GroupedTieredConfig.builder() + Price.GroupedTiered.GroupedTieredConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedTieredPrice.InvoicingCycleConfiguration.builder() + Price.GroupedTiered.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedTieredPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.GroupedTiered.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.GroupedTieredPrice.Item.builder().id("id").name("name").build()) + .item(Price.GroupedTiered.Item.builder().id("id").name("name").build()) .maximum( - Price.GroupedTieredPrice.Maximum.builder() + Price.GroupedTiered.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPrice.Metadata.builder() + Price.GroupedTiered.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedTieredPrice.Minimum.builder() + Price.GroupedTiered.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.GroupedTieredPrice.ModelType.GROUPED_TIERED) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTiered.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedTieredPrice.DimensionalPriceConfiguration.builder() + Price.GroupedTiered.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2285,24 +2215,22 @@ internal class PriceTest { @Test fun ofTieredWithMinimum() { val tieredWithMinimum = - Price.TieredWithMinimumPrice.builder() + Price.TieredWithMinimum.builder() .id("id") - .billableMetric( - Price.TieredWithMinimumPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.TieredWithMinimum.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.TieredWithMinimumPrice.BillingCycleConfiguration.builder() + Price.TieredWithMinimum.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredWithMinimumPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.TieredWithMinimum.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.TieredWithMinimumPrice.Cadence.ONE_TIME) + .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredWithMinimumPrice.CreditAllocation.builder() + Price.TieredWithMinimum.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2320,45 +2248,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredWithMinimumPrice.InvoicingCycleConfiguration.builder() + Price.TieredWithMinimum.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredWithMinimumPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.TieredWithMinimum.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.TieredWithMinimumPrice.Item.builder().id("id").name("name").build()) + .item(Price.TieredWithMinimum.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredWithMinimumPrice.Maximum.builder() + Price.TieredWithMinimum.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithMinimumPrice.Metadata.builder() + Price.TieredWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredWithMinimumPrice.Minimum.builder() + Price.TieredWithMinimum.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredWithMinimumPrice.ModelType.TIERED_WITH_MINIMUM) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithMinimumPrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) .tieredWithMinimumConfig( - Price.TieredWithMinimumPrice.TieredWithMinimumConfig.builder() + Price.TieredWithMinimum.TieredWithMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.TieredWithMinimumPrice.DimensionalPriceConfiguration.builder() + Price.TieredWithMinimum.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2368,7 +2294,7 @@ internal class PriceTest { val price = Price.ofTieredWithMinimum(tieredWithMinimum) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -2402,25 +2328,24 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofTieredWithMinimum( - Price.TieredWithMinimumPrice.builder() + Price.TieredWithMinimum.builder() .id("id") .billableMetric( - Price.TieredWithMinimumPrice.BillableMetric.builder().id("id").build() + Price.TieredWithMinimum.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.TieredWithMinimumPrice.BillingCycleConfiguration.builder() + Price.TieredWithMinimum.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredWithMinimumPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.TieredWithMinimum.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.TieredWithMinimumPrice.Cadence.ONE_TIME) + .cadence(Price.TieredWithMinimum.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredWithMinimumPrice.CreditAllocation.builder() + Price.TieredWithMinimum.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2438,46 +2363,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredWithMinimumPrice.InvoicingCycleConfiguration.builder() + Price.TieredWithMinimum.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredWithMinimumPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + Price.TieredWithMinimum.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.TieredWithMinimumPrice.Item.builder().id("id").name("name").build()) + .item(Price.TieredWithMinimum.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredWithMinimumPrice.Maximum.builder() + Price.TieredWithMinimum.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithMinimumPrice.Metadata.builder() + Price.TieredWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredWithMinimumPrice.Minimum.builder() + Price.TieredWithMinimum.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredWithMinimumPrice.ModelType.TIERED_WITH_MINIMUM) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithMinimumPrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithMinimum.PriceType.USAGE_PRICE) .tieredWithMinimumConfig( - Price.TieredWithMinimumPrice.TieredWithMinimumConfig.builder() + Price.TieredWithMinimum.TieredWithMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.TieredWithMinimumPrice.DimensionalPriceConfiguration.builder() + Price.TieredWithMinimum.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2494,26 +2416,25 @@ internal class PriceTest { @Test fun ofTieredPackageWithMinimum() { val tieredPackageWithMinimum = - Price.TieredPackageWithMinimumPrice.builder() + Price.TieredPackageWithMinimum.builder() .id("id") .billableMetric( - Price.TieredPackageWithMinimumPrice.BillableMetric.builder().id("id").build() + Price.TieredPackageWithMinimum.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.TieredPackageWithMinimumPrice.BillingCycleConfiguration.builder() + Price.TieredPackageWithMinimum.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredPackageWithMinimumPrice.BillingCycleConfiguration - .DurationUnit + Price.TieredPackageWithMinimum.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.TieredPackageWithMinimumPrice.Cadence.ONE_TIME) + .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredPackageWithMinimumPrice.CreditAllocation.builder() + Price.TieredPackageWithMinimum.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2531,50 +2452,44 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredPackageWithMinimumPrice.InvoicingCycleConfiguration.builder() + Price.TieredPackageWithMinimum.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredPackageWithMinimumPrice.InvoicingCycleConfiguration - .DurationUnit + Price.TieredPackageWithMinimum.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.TieredPackageWithMinimumPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.TieredPackageWithMinimum.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredPackageWithMinimumPrice.Maximum.builder() + Price.TieredPackageWithMinimum.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackageWithMinimumPrice.Metadata.builder() + Price.TieredPackageWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredPackageWithMinimumPrice.Minimum.builder() + Price.TieredPackageWithMinimum.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.TieredPackageWithMinimumPrice.ModelType.TIERED_PACKAGE_WITH_MINIMUM - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPackageWithMinimumPrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredPackageWithMinimum.PriceType.USAGE_PRICE) .tieredPackageWithMinimumConfig( - Price.TieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.builder() + Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.TieredPackageWithMinimumPrice.DimensionalPriceConfiguration.builder() + Price.TieredPackageWithMinimum.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2584,7 +2499,7 @@ internal class PriceTest { val price = Price.ofTieredPackageWithMinimum(tieredPackageWithMinimum) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -2618,28 +2533,26 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofTieredPackageWithMinimum( - Price.TieredPackageWithMinimumPrice.builder() + Price.TieredPackageWithMinimum.builder() .id("id") .billableMetric( - Price.TieredPackageWithMinimumPrice.BillableMetric.builder() - .id("id") - .build() + Price.TieredPackageWithMinimum.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.TieredPackageWithMinimumPrice.BillingCycleConfiguration.builder() + Price.TieredPackageWithMinimum.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredPackageWithMinimumPrice.BillingCycleConfiguration + Price.TieredPackageWithMinimum.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.TieredPackageWithMinimumPrice.Cadence.ONE_TIME) + .cadence(Price.TieredPackageWithMinimum.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredPackageWithMinimumPrice.CreditAllocation.builder() + Price.TieredPackageWithMinimum.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2657,53 +2570,47 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredPackageWithMinimumPrice.InvoicingCycleConfiguration.builder() + Price.TieredPackageWithMinimum.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredPackageWithMinimumPrice.InvoicingCycleConfiguration + Price.TieredPackageWithMinimum.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.TieredPackageWithMinimumPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.TieredPackageWithMinimum.Item.builder().id("id").name("name").build() ) .maximum( - Price.TieredPackageWithMinimumPrice.Maximum.builder() + Price.TieredPackageWithMinimum.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredPackageWithMinimumPrice.Metadata.builder() + Price.TieredPackageWithMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredPackageWithMinimumPrice.Minimum.builder() + Price.TieredPackageWithMinimum.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.TieredPackageWithMinimumPrice.ModelType.TIERED_PACKAGE_WITH_MINIMUM - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredPackageWithMinimumPrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredPackageWithMinimum.PriceType.USAGE_PRICE) .tieredPackageWithMinimumConfig( - Price.TieredPackageWithMinimumPrice.TieredPackageWithMinimumConfig.builder() + Price.TieredPackageWithMinimum.TieredPackageWithMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.TieredPackageWithMinimumPrice.DimensionalPriceConfiguration.builder() + Price.TieredPackageWithMinimum.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2720,25 +2627,24 @@ internal class PriceTest { @Test fun ofPackageWithAllocation() { val packageWithAllocation = - Price.PackageWithAllocationPrice.builder() + Price.PackageWithAllocation.builder() .id("id") .billableMetric( - Price.PackageWithAllocationPrice.BillableMetric.builder().id("id").build() + Price.PackageWithAllocation.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.PackageWithAllocationPrice.BillingCycleConfiguration.builder() + Price.PackageWithAllocation.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.PackageWithAllocationPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.PackageWithAllocation.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.PackageWithAllocationPrice.Cadence.ONE_TIME) + .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.PackageWithAllocationPrice.CreditAllocation.builder() + Price.PackageWithAllocation.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2756,46 +2662,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.PackageWithAllocationPrice.InvoicingCycleConfiguration.builder() + Price.PackageWithAllocation.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.PackageWithAllocationPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + Price.PackageWithAllocation.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.PackageWithAllocationPrice.Item.builder().id("id").name("name").build()) + .item(Price.PackageWithAllocation.Item.builder().id("id").name("name").build()) .maximum( - Price.PackageWithAllocationPrice.Maximum.builder() + Price.PackageWithAllocation.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.PackageWithAllocationPrice.Metadata.builder() + Price.PackageWithAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.PackageWithAllocationPrice.Minimum.builder() + Price.PackageWithAllocation.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.PackageWithAllocationPrice.ModelType.PACKAGE_WITH_ALLOCATION) .name("name") .packageWithAllocationConfig( - Price.PackageWithAllocationPrice.PackageWithAllocationConfig.builder() + Price.PackageWithAllocation.PackageWithAllocationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .planPhaseOrder(0L) - .priceType(Price.PackageWithAllocationPrice.PriceType.USAGE_PRICE) + .priceType(Price.PackageWithAllocation.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.PackageWithAllocationPrice.DimensionalPriceConfiguration.builder() + Price.PackageWithAllocation.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2805,7 +2708,7 @@ internal class PriceTest { val price = Price.ofPackageWithAllocation(packageWithAllocation) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -2839,26 +2742,25 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofPackageWithAllocation( - Price.PackageWithAllocationPrice.builder() + Price.PackageWithAllocation.builder() .id("id") .billableMetric( - Price.PackageWithAllocationPrice.BillableMetric.builder().id("id").build() + Price.PackageWithAllocation.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.PackageWithAllocationPrice.BillingCycleConfiguration.builder() + Price.PackageWithAllocation.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.PackageWithAllocationPrice.BillingCycleConfiguration - .DurationUnit + Price.PackageWithAllocation.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.PackageWithAllocationPrice.Cadence.ONE_TIME) + .cadence(Price.PackageWithAllocation.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.PackageWithAllocationPrice.CreditAllocation.builder() + Price.PackageWithAllocation.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2876,51 +2778,44 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.PackageWithAllocationPrice.InvoicingCycleConfiguration.builder() + Price.PackageWithAllocation.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.PackageWithAllocationPrice.InvoicingCycleConfiguration - .DurationUnit + Price.PackageWithAllocation.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.PackageWithAllocationPrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(Price.PackageWithAllocation.Item.builder().id("id").name("name").build()) .maximum( - Price.PackageWithAllocationPrice.Maximum.builder() + Price.PackageWithAllocation.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.PackageWithAllocationPrice.Metadata.builder() + Price.PackageWithAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.PackageWithAllocationPrice.Minimum.builder() + Price.PackageWithAllocation.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.PackageWithAllocationPrice.ModelType.PACKAGE_WITH_ALLOCATION) .name("name") .packageWithAllocationConfig( - Price.PackageWithAllocationPrice.PackageWithAllocationConfig.builder() + Price.PackageWithAllocation.PackageWithAllocationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .planPhaseOrder(0L) - .priceType(Price.PackageWithAllocationPrice.PriceType.USAGE_PRICE) + .priceType(Price.PackageWithAllocation.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.PackageWithAllocationPrice.DimensionalPriceConfiguration.builder() + Price.PackageWithAllocation.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2937,24 +2832,22 @@ internal class PriceTest { @Test fun ofUnitWithPercent() { val unitWithPercent = - Price.UnitWithPercentPrice.builder() + Price.UnitWithPercent.builder() .id("id") - .billableMetric( - Price.UnitWithPercentPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.UnitWithPercent.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitWithPercentPrice.BillingCycleConfiguration.builder() + Price.UnitWithPercent.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitWithPercentPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.UnitWithPercent.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitWithPercentPrice.Cadence.ONE_TIME) + .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitWithPercentPrice.CreditAllocation.builder() + Price.UnitWithPercent.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2972,44 +2865,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitWithPercentPrice.InvoicingCycleConfiguration.builder() + Price.UnitWithPercent.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitWithPercentPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.UnitWithPercent.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitWithPercentPrice.Item.builder().id("id").name("name").build()) + .item(Price.UnitWithPercent.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitWithPercentPrice.Maximum.builder() + Price.UnitWithPercent.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithPercentPrice.Metadata.builder() + Price.UnitWithPercent.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitWithPercentPrice.Minimum.builder() + Price.UnitWithPercent.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitWithPercentPrice.ModelType.UNIT_WITH_PERCENT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithPercentPrice.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithPercent.PriceType.USAGE_PRICE) .unitWithPercentConfig( - Price.UnitWithPercentPrice.UnitWithPercentConfig.builder() + Price.UnitWithPercent.UnitWithPercentConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.UnitWithPercentPrice.DimensionalPriceConfiguration.builder() + Price.UnitWithPercent.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3019,7 +2911,7 @@ internal class PriceTest { val price = Price.ofUnitWithPercent(unitWithPercent) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -3053,25 +2945,22 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofUnitWithPercent( - Price.UnitWithPercentPrice.builder() + Price.UnitWithPercent.builder() .id("id") - .billableMetric( - Price.UnitWithPercentPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.UnitWithPercent.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitWithPercentPrice.BillingCycleConfiguration.builder() + Price.UnitWithPercent.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitWithPercentPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.UnitWithPercent.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitWithPercentPrice.Cadence.ONE_TIME) + .cadence(Price.UnitWithPercent.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitWithPercentPrice.CreditAllocation.builder() + Price.UnitWithPercent.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3089,45 +2978,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitWithPercentPrice.InvoicingCycleConfiguration.builder() + Price.UnitWithPercent.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitWithPercentPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.UnitWithPercent.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitWithPercentPrice.Item.builder().id("id").name("name").build()) + .item(Price.UnitWithPercent.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitWithPercentPrice.Maximum.builder() + Price.UnitWithPercent.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithPercentPrice.Metadata.builder() + Price.UnitWithPercent.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitWithPercentPrice.Minimum.builder() + Price.UnitWithPercent.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitWithPercentPrice.ModelType.UNIT_WITH_PERCENT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithPercentPrice.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithPercent.PriceType.USAGE_PRICE) .unitWithPercentConfig( - Price.UnitWithPercentPrice.UnitWithPercentConfig.builder() + Price.UnitWithPercent.UnitWithPercentConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.UnitWithPercentPrice.DimensionalPriceConfiguration.builder() + Price.UnitWithPercent.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3144,25 +3031,24 @@ internal class PriceTest { @Test fun ofMatrixWithAllocation() { val matrixWithAllocation = - Price.MatrixWithAllocationPrice.builder() + Price.MatrixWithAllocation.builder() .id("id") .billableMetric( - Price.MatrixWithAllocationPrice.BillableMetric.builder().id("id").build() + Price.MatrixWithAllocation.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.MatrixWithAllocationPrice.BillingCycleConfiguration.builder() + Price.MatrixWithAllocation.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MatrixWithAllocationPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.MatrixWithAllocation.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.MatrixWithAllocationPrice.Cadence.ONE_TIME) + .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.MatrixWithAllocationPrice.CreditAllocation.builder() + Price.MatrixWithAllocation.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3180,22 +3066,21 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.MatrixWithAllocationPrice.InvoicingCycleConfiguration.builder() + Price.MatrixWithAllocation.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MatrixWithAllocationPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.MatrixWithAllocation.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.MatrixWithAllocationPrice.Item.builder().id("id").name("name").build()) + .item(Price.MatrixWithAllocation.Item.builder().id("id").name("name").build()) .matrixWithAllocationConfig( - Price.MatrixWithAllocationPrice.MatrixWithAllocationConfig.builder() + Price.MatrixWithAllocation.MatrixWithAllocationConfig.builder() .allocation(0.0) .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - Price.MatrixWithAllocationPrice.MatrixWithAllocationConfig.MatrixValue + Price.MatrixWithAllocation.MatrixWithAllocationConfig.MatrixValue .builder() .addDimensionValue("string") .unitAmount("unit_amount") @@ -3204,30 +3089,29 @@ internal class PriceTest { .build() ) .maximum( - Price.MatrixWithAllocationPrice.Maximum.builder() + Price.MatrixWithAllocation.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithAllocationPrice.Metadata.builder() + Price.MatrixWithAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.MatrixWithAllocationPrice.Minimum.builder() + Price.MatrixWithAllocation.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.MatrixWithAllocationPrice.ModelType.MATRIX_WITH_ALLOCATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithAllocationPrice.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithAllocation.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.MatrixWithAllocationPrice.DimensionalPriceConfiguration.builder() + Price.MatrixWithAllocation.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3237,7 +3121,7 @@ internal class PriceTest { val price = Price.ofMatrixWithAllocation(matrixWithAllocation) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -3271,26 +3155,25 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofMatrixWithAllocation( - Price.MatrixWithAllocationPrice.builder() + Price.MatrixWithAllocation.builder() .id("id") .billableMetric( - Price.MatrixWithAllocationPrice.BillableMetric.builder().id("id").build() + Price.MatrixWithAllocation.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.MatrixWithAllocationPrice.BillingCycleConfiguration.builder() + Price.MatrixWithAllocation.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MatrixWithAllocationPrice.BillingCycleConfiguration - .DurationUnit + Price.MatrixWithAllocation.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.MatrixWithAllocationPrice.Cadence.ONE_TIME) + .cadence(Price.MatrixWithAllocation.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.MatrixWithAllocationPrice.CreditAllocation.builder() + Price.MatrixWithAllocation.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3308,26 +3191,22 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.MatrixWithAllocationPrice.InvoicingCycleConfiguration.builder() + Price.MatrixWithAllocation.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MatrixWithAllocationPrice.InvoicingCycleConfiguration - .DurationUnit + Price.MatrixWithAllocation.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.MatrixWithAllocationPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.MatrixWithAllocation.Item.builder().id("id").name("name").build()) .matrixWithAllocationConfig( - Price.MatrixWithAllocationPrice.MatrixWithAllocationConfig.builder() + Price.MatrixWithAllocation.MatrixWithAllocationConfig.builder() .allocation(0.0) .defaultUnitAmount("default_unit_amount") .addDimension("string") .addMatrixValue( - Price.MatrixWithAllocationPrice.MatrixWithAllocationConfig - .MatrixValue + Price.MatrixWithAllocation.MatrixWithAllocationConfig.MatrixValue .builder() .addDimensionValue("string") .unitAmount("unit_amount") @@ -3336,30 +3215,29 @@ internal class PriceTest { .build() ) .maximum( - Price.MatrixWithAllocationPrice.Maximum.builder() + Price.MatrixWithAllocation.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithAllocationPrice.Metadata.builder() + Price.MatrixWithAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.MatrixWithAllocationPrice.Minimum.builder() + Price.MatrixWithAllocation.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.MatrixWithAllocationPrice.ModelType.MATRIX_WITH_ALLOCATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithAllocationPrice.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithAllocation.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.MatrixWithAllocationPrice.DimensionalPriceConfiguration.builder() + Price.MatrixWithAllocation.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3376,25 +3254,22 @@ internal class PriceTest { @Test fun ofTieredWithProration() { val tieredWithProration = - Price.TieredWithProrationPrice.builder() + Price.TieredWithProration.builder() .id("id") - .billableMetric( - Price.TieredWithProrationPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.TieredWithProration.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.TieredWithProrationPrice.BillingCycleConfiguration.builder() + Price.TieredWithProration.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredWithProrationPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.TieredWithProration.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.TieredWithProrationPrice.Cadence.ONE_TIME) + .cadence(Price.TieredWithProration.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredWithProrationPrice.CreditAllocation.builder() + Price.TieredWithProration.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3412,45 +3287,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredWithProrationPrice.InvoicingCycleConfiguration.builder() + Price.TieredWithProration.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredWithProrationPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.TieredWithProration.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.TieredWithProrationPrice.Item.builder().id("id").name("name").build()) + .item(Price.TieredWithProration.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredWithProrationPrice.Maximum.builder() + Price.TieredWithProration.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithProrationPrice.Metadata.builder() + Price.TieredWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredWithProrationPrice.Minimum.builder() + Price.TieredWithProration.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredWithProrationPrice.ModelType.TIERED_WITH_PRORATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithProrationPrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) .tieredWithProrationConfig( - Price.TieredWithProrationPrice.TieredWithProrationConfig.builder() + Price.TieredWithProration.TieredWithProrationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.TieredWithProrationPrice.DimensionalPriceConfiguration.builder() + Price.TieredWithProration.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3460,7 +3333,7 @@ internal class PriceTest { val price = Price.ofTieredWithProration(tieredWithProration) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -3494,26 +3367,24 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofTieredWithProration( - Price.TieredWithProrationPrice.builder() + Price.TieredWithProration.builder() .id("id") .billableMetric( - Price.TieredWithProrationPrice.BillableMetric.builder().id("id").build() + Price.TieredWithProration.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.TieredWithProrationPrice.BillingCycleConfiguration.builder() + Price.TieredWithProration.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredWithProrationPrice.BillingCycleConfiguration - .DurationUnit - .DAY + Price.TieredWithProration.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.TieredWithProrationPrice.Cadence.ONE_TIME) + .cadence(Price.TieredWithProration.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.TieredWithProrationPrice.CreditAllocation.builder() + Price.TieredWithProration.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3531,48 +3402,44 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.TieredWithProrationPrice.InvoicingCycleConfiguration.builder() + Price.TieredWithProration.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.TieredWithProrationPrice.InvoicingCycleConfiguration - .DurationUnit + Price.TieredWithProration.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.TieredWithProrationPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.TieredWithProration.Item.builder().id("id").name("name").build()) .maximum( - Price.TieredWithProrationPrice.Maximum.builder() + Price.TieredWithProration.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.TieredWithProrationPrice.Metadata.builder() + Price.TieredWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.TieredWithProrationPrice.Minimum.builder() + Price.TieredWithProration.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.TieredWithProrationPrice.ModelType.TIERED_WITH_PRORATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.TieredWithProrationPrice.PriceType.USAGE_PRICE) + .priceType(Price.TieredWithProration.PriceType.USAGE_PRICE) .tieredWithProrationConfig( - Price.TieredWithProrationPrice.TieredWithProrationConfig.builder() + Price.TieredWithProration.TieredWithProrationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.TieredWithProrationPrice.DimensionalPriceConfiguration.builder() + Price.TieredWithProration.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3589,24 +3456,22 @@ internal class PriceTest { @Test fun ofUnitWithProration() { val unitWithProration = - Price.UnitWithProrationPrice.builder() + Price.UnitWithProration.builder() .id("id") - .billableMetric( - Price.UnitWithProrationPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.UnitWithProration.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitWithProrationPrice.BillingCycleConfiguration.builder() + Price.UnitWithProration.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitWithProrationPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.UnitWithProration.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitWithProrationPrice.Cadence.ONE_TIME) + .cadence(Price.UnitWithProration.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitWithProrationPrice.CreditAllocation.builder() + Price.UnitWithProration.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3624,45 +3489,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitWithProrationPrice.InvoicingCycleConfiguration.builder() + Price.UnitWithProration.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitWithProrationPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.UnitWithProration.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitWithProrationPrice.Item.builder().id("id").name("name").build()) + .item(Price.UnitWithProration.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitWithProrationPrice.Maximum.builder() + Price.UnitWithProration.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithProrationPrice.Metadata.builder() + Price.UnitWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitWithProrationPrice.Minimum.builder() + Price.UnitWithProration.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitWithProrationPrice.ModelType.UNIT_WITH_PRORATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithProrationPrice.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) .unitWithProrationConfig( - Price.UnitWithProrationPrice.UnitWithProrationConfig.builder() + Price.UnitWithProration.UnitWithProrationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.UnitWithProrationPrice.DimensionalPriceConfiguration.builder() + Price.UnitWithProration.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3672,7 +3535,7 @@ internal class PriceTest { val price = Price.ofUnitWithProration(unitWithProration) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -3706,25 +3569,24 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofUnitWithProration( - Price.UnitWithProrationPrice.builder() + Price.UnitWithProration.builder() .id("id") .billableMetric( - Price.UnitWithProrationPrice.BillableMetric.builder().id("id").build() + Price.UnitWithProration.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitWithProrationPrice.BillingCycleConfiguration.builder() + Price.UnitWithProration.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitWithProrationPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.UnitWithProration.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitWithProrationPrice.Cadence.ONE_TIME) + .cadence(Price.UnitWithProration.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitWithProrationPrice.CreditAllocation.builder() + Price.UnitWithProration.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3742,46 +3604,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitWithProrationPrice.InvoicingCycleConfiguration.builder() + Price.UnitWithProration.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitWithProrationPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + Price.UnitWithProration.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitWithProrationPrice.Item.builder().id("id").name("name").build()) + .item(Price.UnitWithProration.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitWithProrationPrice.Maximum.builder() + Price.UnitWithProration.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitWithProrationPrice.Metadata.builder() + Price.UnitWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitWithProrationPrice.Minimum.builder() + Price.UnitWithProration.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitWithProrationPrice.ModelType.UNIT_WITH_PRORATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitWithProrationPrice.PriceType.USAGE_PRICE) + .priceType(Price.UnitWithProration.PriceType.USAGE_PRICE) .unitWithProrationConfig( - Price.UnitWithProrationPrice.UnitWithProrationConfig.builder() + Price.UnitWithProration.UnitWithProrationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.UnitWithProrationPrice.DimensionalPriceConfiguration.builder() + Price.UnitWithProration.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3798,24 +3657,22 @@ internal class PriceTest { @Test fun ofGroupedAllocation() { val groupedAllocation = - Price.GroupedAllocationPrice.builder() + Price.GroupedAllocation.builder() .id("id") - .billableMetric( - Price.GroupedAllocationPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.GroupedAllocation.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.GroupedAllocationPrice.BillingCycleConfiguration.builder() + Price.GroupedAllocation.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedAllocationPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.GroupedAllocation.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.GroupedAllocationPrice.Cadence.ONE_TIME) + .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedAllocationPrice.CreditAllocation.builder() + Price.GroupedAllocation.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3833,45 +3690,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedAllocationConfig( - Price.GroupedAllocationPrice.GroupedAllocationConfig.builder() + Price.GroupedAllocation.GroupedAllocationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedAllocationPrice.InvoicingCycleConfiguration.builder() + Price.GroupedAllocation.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedAllocationPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.GroupedAllocation.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.GroupedAllocationPrice.Item.builder().id("id").name("name").build()) + .item(Price.GroupedAllocation.Item.builder().id("id").name("name").build()) .maximum( - Price.GroupedAllocationPrice.Maximum.builder() + Price.GroupedAllocation.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedAllocationPrice.Metadata.builder() + Price.GroupedAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedAllocationPrice.Minimum.builder() + Price.GroupedAllocation.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.GroupedAllocationPrice.ModelType.GROUPED_ALLOCATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedAllocationPrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedAllocationPrice.DimensionalPriceConfiguration.builder() + Price.GroupedAllocation.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3881,7 +3736,7 @@ internal class PriceTest { val price = Price.ofGroupedAllocation(groupedAllocation) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -3915,25 +3770,24 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofGroupedAllocation( - Price.GroupedAllocationPrice.builder() + Price.GroupedAllocation.builder() .id("id") .billableMetric( - Price.GroupedAllocationPrice.BillableMetric.builder().id("id").build() + Price.GroupedAllocation.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.GroupedAllocationPrice.BillingCycleConfiguration.builder() + Price.GroupedAllocation.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedAllocationPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.GroupedAllocation.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.GroupedAllocationPrice.Cadence.ONE_TIME) + .cadence(Price.GroupedAllocation.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedAllocationPrice.CreditAllocation.builder() + Price.GroupedAllocation.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3951,46 +3805,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedAllocationConfig( - Price.GroupedAllocationPrice.GroupedAllocationConfig.builder() + Price.GroupedAllocation.GroupedAllocationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedAllocationPrice.InvoicingCycleConfiguration.builder() + Price.GroupedAllocation.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedAllocationPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + Price.GroupedAllocation.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.GroupedAllocationPrice.Item.builder().id("id").name("name").build()) + .item(Price.GroupedAllocation.Item.builder().id("id").name("name").build()) .maximum( - Price.GroupedAllocationPrice.Maximum.builder() + Price.GroupedAllocation.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedAllocationPrice.Metadata.builder() + Price.GroupedAllocation.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedAllocationPrice.Minimum.builder() + Price.GroupedAllocation.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.GroupedAllocationPrice.ModelType.GROUPED_ALLOCATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedAllocationPrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedAllocation.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedAllocationPrice.DimensionalPriceConfiguration.builder() + Price.GroupedAllocation.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4007,26 +3858,25 @@ internal class PriceTest { @Test fun ofGroupedWithProratedMinimum() { val groupedWithProratedMinimum = - Price.GroupedWithProratedMinimumPrice.builder() + Price.GroupedWithProratedMinimum.builder() .id("id") .billableMetric( - Price.GroupedWithProratedMinimumPrice.BillableMetric.builder().id("id").build() + Price.GroupedWithProratedMinimum.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.GroupedWithProratedMinimumPrice.BillingCycleConfiguration.builder() + Price.GroupedWithProratedMinimum.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedWithProratedMinimumPrice.BillingCycleConfiguration - .DurationUnit + Price.GroupedWithProratedMinimum.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.GroupedWithProratedMinimumPrice.Cadence.ONE_TIME) + .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedWithProratedMinimumPrice.CreditAllocation.builder() + Price.GroupedWithProratedMinimum.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4044,53 +3894,45 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedWithProratedMinimumConfig( - Price.GroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig.builder() + Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedWithProratedMinimumPrice.InvoicingCycleConfiguration.builder() + Price.GroupedWithProratedMinimum.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedWithProratedMinimumPrice.InvoicingCycleConfiguration + Price.GroupedWithProratedMinimum.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) - .item( - Price.GroupedWithProratedMinimumPrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(Price.GroupedWithProratedMinimum.Item.builder().id("id").name("name").build()) .maximum( - Price.GroupedWithProratedMinimumPrice.Maximum.builder() + Price.GroupedWithProratedMinimum.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithProratedMinimumPrice.Metadata.builder() + Price.GroupedWithProratedMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedWithProratedMinimumPrice.Minimum.builder() + Price.GroupedWithProratedMinimum.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.GroupedWithProratedMinimumPrice.ModelType.GROUPED_WITH_PRORATED_MINIMUM - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithProratedMinimumPrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedWithProratedMinimumPrice.DimensionalPriceConfiguration.builder() + Price.GroupedWithProratedMinimum.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4100,7 +3942,7 @@ internal class PriceTest { val price = Price.ofGroupedWithProratedMinimum(groupedWithProratedMinimum) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -4134,28 +3976,26 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofGroupedWithProratedMinimum( - Price.GroupedWithProratedMinimumPrice.builder() + Price.GroupedWithProratedMinimum.builder() .id("id") .billableMetric( - Price.GroupedWithProratedMinimumPrice.BillableMetric.builder() - .id("id") - .build() + Price.GroupedWithProratedMinimum.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.GroupedWithProratedMinimumPrice.BillingCycleConfiguration.builder() + Price.GroupedWithProratedMinimum.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedWithProratedMinimumPrice.BillingCycleConfiguration + Price.GroupedWithProratedMinimum.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.GroupedWithProratedMinimumPrice.Cadence.ONE_TIME) + .cadence(Price.GroupedWithProratedMinimum.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedWithProratedMinimumPrice.CreditAllocation.builder() + Price.GroupedWithProratedMinimum.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4173,56 +4013,50 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedWithProratedMinimumConfig( - Price.GroupedWithProratedMinimumPrice.GroupedWithProratedMinimumConfig - .builder() + Price.GroupedWithProratedMinimum.GroupedWithProratedMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedWithProratedMinimumPrice.InvoicingCycleConfiguration.builder() + Price.GroupedWithProratedMinimum.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedWithProratedMinimumPrice.InvoicingCycleConfiguration + Price.GroupedWithProratedMinimum.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.GroupedWithProratedMinimumPrice.Item.builder() + Price.GroupedWithProratedMinimum.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.GroupedWithProratedMinimumPrice.Maximum.builder() + Price.GroupedWithProratedMinimum.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithProratedMinimumPrice.Metadata.builder() + Price.GroupedWithProratedMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedWithProratedMinimumPrice.Minimum.builder() + Price.GroupedWithProratedMinimum.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.GroupedWithProratedMinimumPrice.ModelType - .GROUPED_WITH_PRORATED_MINIMUM - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithProratedMinimumPrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithProratedMinimum.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedWithProratedMinimumPrice.DimensionalPriceConfiguration - .builder() + Price.GroupedWithProratedMinimum.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4239,26 +4073,25 @@ internal class PriceTest { @Test fun ofGroupedWithMeteredMinimum() { val groupedWithMeteredMinimum = - Price.GroupedWithMeteredMinimumPrice.builder() + Price.GroupedWithMeteredMinimum.builder() .id("id") .billableMetric( - Price.GroupedWithMeteredMinimumPrice.BillableMetric.builder().id("id").build() + Price.GroupedWithMeteredMinimum.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.GroupedWithMeteredMinimumPrice.BillingCycleConfiguration.builder() + Price.GroupedWithMeteredMinimum.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedWithMeteredMinimumPrice.BillingCycleConfiguration - .DurationUnit + Price.GroupedWithMeteredMinimum.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.GroupedWithMeteredMinimumPrice.Cadence.ONE_TIME) + .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedWithMeteredMinimumPrice.CreditAllocation.builder() + Price.GroupedWithMeteredMinimum.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4276,53 +4109,44 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedWithMeteredMinimumConfig( - Price.GroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig.builder() + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedWithMeteredMinimumPrice.InvoicingCycleConfiguration.builder() + Price.GroupedWithMeteredMinimum.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedWithMeteredMinimumPrice.InvoicingCycleConfiguration - .DurationUnit + Price.GroupedWithMeteredMinimum.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.GroupedWithMeteredMinimumPrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(Price.GroupedWithMeteredMinimum.Item.builder().id("id").name("name").build()) .maximum( - Price.GroupedWithMeteredMinimumPrice.Maximum.builder() + Price.GroupedWithMeteredMinimum.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMeteredMinimumPrice.Metadata.builder() + Price.GroupedWithMeteredMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedWithMeteredMinimumPrice.Minimum.builder() + Price.GroupedWithMeteredMinimum.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.GroupedWithMeteredMinimumPrice.ModelType.GROUPED_WITH_METERED_MINIMUM - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMeteredMinimumPrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedWithMeteredMinimumPrice.DimensionalPriceConfiguration.builder() + Price.GroupedWithMeteredMinimum.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4332,7 +4156,7 @@ internal class PriceTest { val price = Price.ofGroupedWithMeteredMinimum(groupedWithMeteredMinimum) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -4366,28 +4190,26 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofGroupedWithMeteredMinimum( - Price.GroupedWithMeteredMinimumPrice.builder() + Price.GroupedWithMeteredMinimum.builder() .id("id") .billableMetric( - Price.GroupedWithMeteredMinimumPrice.BillableMetric.builder() - .id("id") - .build() + Price.GroupedWithMeteredMinimum.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.GroupedWithMeteredMinimumPrice.BillingCycleConfiguration.builder() + Price.GroupedWithMeteredMinimum.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedWithMeteredMinimumPrice.BillingCycleConfiguration + Price.GroupedWithMeteredMinimum.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.GroupedWithMeteredMinimumPrice.Cadence.ONE_TIME) + .cadence(Price.GroupedWithMeteredMinimum.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedWithMeteredMinimumPrice.CreditAllocation.builder() + Price.GroupedWithMeteredMinimum.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4405,54 +4227,47 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedWithMeteredMinimumConfig( - Price.GroupedWithMeteredMinimumPrice.GroupedWithMeteredMinimumConfig - .builder() + Price.GroupedWithMeteredMinimum.GroupedWithMeteredMinimumConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedWithMeteredMinimumPrice.InvoicingCycleConfiguration.builder() + Price.GroupedWithMeteredMinimum.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedWithMeteredMinimumPrice.InvoicingCycleConfiguration + Price.GroupedWithMeteredMinimum.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.GroupedWithMeteredMinimumPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.GroupedWithMeteredMinimum.Item.builder().id("id").name("name").build() ) .maximum( - Price.GroupedWithMeteredMinimumPrice.Maximum.builder() + Price.GroupedWithMeteredMinimum.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedWithMeteredMinimumPrice.Metadata.builder() + Price.GroupedWithMeteredMinimum.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedWithMeteredMinimumPrice.Minimum.builder() + Price.GroupedWithMeteredMinimum.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.GroupedWithMeteredMinimumPrice.ModelType.GROUPED_WITH_METERED_MINIMUM - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedWithMeteredMinimumPrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedWithMeteredMinimum.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedWithMeteredMinimumPrice.DimensionalPriceConfiguration.builder() + Price.GroupedWithMeteredMinimum.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4469,25 +4284,24 @@ internal class PriceTest { @Test fun ofMatrixWithDisplayName() { val matrixWithDisplayName = - Price.MatrixWithDisplayNamePrice.builder() + Price.MatrixWithDisplayName.builder() .id("id") .billableMetric( - Price.MatrixWithDisplayNamePrice.BillableMetric.builder().id("id").build() + Price.MatrixWithDisplayName.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.MatrixWithDisplayNamePrice.BillingCycleConfiguration.builder() + Price.MatrixWithDisplayName.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MatrixWithDisplayNamePrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.MatrixWithDisplayName.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.MatrixWithDisplayNamePrice.Cadence.ONE_TIME) + .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.MatrixWithDisplayNamePrice.CreditAllocation.builder() + Price.MatrixWithDisplayName.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4505,46 +4319,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.MatrixWithDisplayNamePrice.InvoicingCycleConfiguration.builder() + Price.MatrixWithDisplayName.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MatrixWithDisplayNamePrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + Price.MatrixWithDisplayName.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.MatrixWithDisplayNamePrice.Item.builder().id("id").name("name").build()) + .item(Price.MatrixWithDisplayName.Item.builder().id("id").name("name").build()) .matrixWithDisplayNameConfig( - Price.MatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .maximum( - Price.MatrixWithDisplayNamePrice.Maximum.builder() + Price.MatrixWithDisplayName.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithDisplayNamePrice.Metadata.builder() + Price.MatrixWithDisplayName.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.MatrixWithDisplayNamePrice.Minimum.builder() + Price.MatrixWithDisplayName.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.MatrixWithDisplayNamePrice.ModelType.MATRIX_WITH_DISPLAY_NAME) .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithDisplayNamePrice.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.MatrixWithDisplayNamePrice.DimensionalPriceConfiguration.builder() + Price.MatrixWithDisplayName.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4554,7 +4365,7 @@ internal class PriceTest { val price = Price.ofMatrixWithDisplayName(matrixWithDisplayName) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -4588,26 +4399,25 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofMatrixWithDisplayName( - Price.MatrixWithDisplayNamePrice.builder() + Price.MatrixWithDisplayName.builder() .id("id") .billableMetric( - Price.MatrixWithDisplayNamePrice.BillableMetric.builder().id("id").build() + Price.MatrixWithDisplayName.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.MatrixWithDisplayNamePrice.BillingCycleConfiguration.builder() + Price.MatrixWithDisplayName.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MatrixWithDisplayNamePrice.BillingCycleConfiguration - .DurationUnit + Price.MatrixWithDisplayName.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.MatrixWithDisplayNamePrice.Cadence.ONE_TIME) + .cadence(Price.MatrixWithDisplayName.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.MatrixWithDisplayNamePrice.CreditAllocation.builder() + Price.MatrixWithDisplayName.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4625,51 +4435,44 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.MatrixWithDisplayNamePrice.InvoicingCycleConfiguration.builder() + Price.MatrixWithDisplayName.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MatrixWithDisplayNamePrice.InvoicingCycleConfiguration - .DurationUnit + Price.MatrixWithDisplayName.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.MatrixWithDisplayNamePrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(Price.MatrixWithDisplayName.Item.builder().id("id").name("name").build()) .matrixWithDisplayNameConfig( - Price.MatrixWithDisplayNamePrice.MatrixWithDisplayNameConfig.builder() + Price.MatrixWithDisplayName.MatrixWithDisplayNameConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .maximum( - Price.MatrixWithDisplayNamePrice.Maximum.builder() + Price.MatrixWithDisplayName.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.MatrixWithDisplayNamePrice.Metadata.builder() + Price.MatrixWithDisplayName.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.MatrixWithDisplayNamePrice.Minimum.builder() + Price.MatrixWithDisplayName.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.MatrixWithDisplayNamePrice.ModelType.MATRIX_WITH_DISPLAY_NAME) .name("name") .planPhaseOrder(0L) - .priceType(Price.MatrixWithDisplayNamePrice.PriceType.USAGE_PRICE) + .priceType(Price.MatrixWithDisplayName.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.MatrixWithDisplayNamePrice.DimensionalPriceConfiguration.builder() + Price.MatrixWithDisplayName.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4686,29 +4489,27 @@ internal class PriceTest { @Test fun ofBulkWithProration() { val bulkWithProration = - Price.BulkWithProrationPrice.builder() + Price.BulkWithProration.builder() .id("id") - .billableMetric( - Price.BulkWithProrationPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.BulkWithProration.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.BulkWithProrationPrice.BillingCycleConfiguration.builder() + Price.BulkWithProration.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.BulkWithProrationPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.BulkWithProration.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) .bulkWithProrationConfig( - Price.BulkWithProrationPrice.BulkWithProrationConfig.builder() + Price.BulkWithProration.BulkWithProrationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .cadence(Price.BulkWithProrationPrice.Cadence.ONE_TIME) + .cadence(Price.BulkWithProration.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.BulkWithProrationPrice.CreditAllocation.builder() + Price.BulkWithProration.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4726,40 +4527,38 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.BulkWithProrationPrice.InvoicingCycleConfiguration.builder() + Price.BulkWithProration.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.BulkWithProrationPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.BulkWithProration.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.BulkWithProrationPrice.Item.builder().id("id").name("name").build()) + .item(Price.BulkWithProration.Item.builder().id("id").name("name").build()) .maximum( - Price.BulkWithProrationPrice.Maximum.builder() + Price.BulkWithProration.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.BulkWithProrationPrice.Metadata.builder() + Price.BulkWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.BulkWithProrationPrice.Minimum.builder() + Price.BulkWithProration.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.BulkWithProrationPrice.ModelType.BULK_WITH_PRORATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkWithProrationPrice.PriceType.USAGE_PRICE) + .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.BulkWithProrationPrice.DimensionalPriceConfiguration.builder() + Price.BulkWithProration.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4769,7 +4568,7 @@ internal class PriceTest { val price = Price.ofBulkWithProration(bulkWithProration) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -4803,30 +4602,29 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofBulkWithProration( - Price.BulkWithProrationPrice.builder() + Price.BulkWithProration.builder() .id("id") .billableMetric( - Price.BulkWithProrationPrice.BillableMetric.builder().id("id").build() + Price.BulkWithProration.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.BulkWithProrationPrice.BillingCycleConfiguration.builder() + Price.BulkWithProration.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.BulkWithProrationPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.BulkWithProration.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) .bulkWithProrationConfig( - Price.BulkWithProrationPrice.BulkWithProrationConfig.builder() + Price.BulkWithProration.BulkWithProrationConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .cadence(Price.BulkWithProrationPrice.Cadence.ONE_TIME) + .cadence(Price.BulkWithProration.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.BulkWithProrationPrice.CreditAllocation.builder() + Price.BulkWithProration.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4844,41 +4642,38 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.BulkWithProrationPrice.InvoicingCycleConfiguration.builder() + Price.BulkWithProration.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.BulkWithProrationPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + Price.BulkWithProration.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.BulkWithProrationPrice.Item.builder().id("id").name("name").build()) + .item(Price.BulkWithProration.Item.builder().id("id").name("name").build()) .maximum( - Price.BulkWithProrationPrice.Maximum.builder() + Price.BulkWithProration.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.BulkWithProrationPrice.Metadata.builder() + Price.BulkWithProration.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.BulkWithProrationPrice.Minimum.builder() + Price.BulkWithProration.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.BulkWithProrationPrice.ModelType.BULK_WITH_PRORATION) .name("name") .planPhaseOrder(0L) - .priceType(Price.BulkWithProrationPrice.PriceType.USAGE_PRICE) + .priceType(Price.BulkWithProration.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.BulkWithProrationPrice.DimensionalPriceConfiguration.builder() + Price.BulkWithProration.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4895,25 +4690,24 @@ internal class PriceTest { @Test fun ofGroupedTieredPackage() { val groupedTieredPackage = - Price.GroupedTieredPackagePrice.builder() + Price.GroupedTieredPackage.builder() .id("id") .billableMetric( - Price.GroupedTieredPackagePrice.BillableMetric.builder().id("id").build() + Price.GroupedTieredPackage.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.GroupedTieredPackagePrice.BillingCycleConfiguration.builder() + Price.GroupedTieredPackage.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedTieredPackagePrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.GroupedTieredPackage.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.GroupedTieredPackagePrice.Cadence.ONE_TIME) + .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedTieredPackagePrice.CreditAllocation.builder() + Price.GroupedTieredPackage.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4931,45 +4725,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedTieredPackageConfig( - Price.GroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() + Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedTieredPackagePrice.InvoicingCycleConfiguration.builder() + Price.GroupedTieredPackage.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedTieredPackagePrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.GroupedTieredPackage.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.GroupedTieredPackagePrice.Item.builder().id("id").name("name").build()) + .item(Price.GroupedTieredPackage.Item.builder().id("id").name("name").build()) .maximum( - Price.GroupedTieredPackagePrice.Maximum.builder() + Price.GroupedTieredPackage.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPackagePrice.Metadata.builder() + Price.GroupedTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedTieredPackagePrice.Minimum.builder() + Price.GroupedTieredPackage.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.GroupedTieredPackagePrice.ModelType.GROUPED_TIERED_PACKAGE) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPackagePrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedTieredPackagePrice.DimensionalPriceConfiguration.builder() + Price.GroupedTieredPackage.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -4979,7 +4771,7 @@ internal class PriceTest { val price = Price.ofGroupedTieredPackage(groupedTieredPackage) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -5013,26 +4805,25 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofGroupedTieredPackage( - Price.GroupedTieredPackagePrice.builder() + Price.GroupedTieredPackage.builder() .id("id") .billableMetric( - Price.GroupedTieredPackagePrice.BillableMetric.builder().id("id").build() + Price.GroupedTieredPackage.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.GroupedTieredPackagePrice.BillingCycleConfiguration.builder() + Price.GroupedTieredPackage.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedTieredPackagePrice.BillingCycleConfiguration - .DurationUnit + Price.GroupedTieredPackage.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.GroupedTieredPackagePrice.Cadence.ONE_TIME) + .cadence(Price.GroupedTieredPackage.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.GroupedTieredPackagePrice.CreditAllocation.builder() + Price.GroupedTieredPackage.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -5050,48 +4841,44 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .groupedTieredPackageConfig( - Price.GroupedTieredPackagePrice.GroupedTieredPackageConfig.builder() + Price.GroupedTieredPackage.GroupedTieredPackageConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .invoicingCycleConfiguration( - Price.GroupedTieredPackagePrice.InvoicingCycleConfiguration.builder() + Price.GroupedTieredPackage.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.GroupedTieredPackagePrice.InvoicingCycleConfiguration - .DurationUnit + Price.GroupedTieredPackage.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.GroupedTieredPackagePrice.Item.builder().id("id").name("name").build() - ) + .item(Price.GroupedTieredPackage.Item.builder().id("id").name("name").build()) .maximum( - Price.GroupedTieredPackagePrice.Maximum.builder() + Price.GroupedTieredPackage.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.GroupedTieredPackagePrice.Metadata.builder() + Price.GroupedTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.GroupedTieredPackagePrice.Minimum.builder() + Price.GroupedTieredPackage.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.GroupedTieredPackagePrice.ModelType.GROUPED_TIERED_PACKAGE) .name("name") .planPhaseOrder(0L) - .priceType(Price.GroupedTieredPackagePrice.PriceType.USAGE_PRICE) + .priceType(Price.GroupedTieredPackage.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.GroupedTieredPackagePrice.DimensionalPriceConfiguration.builder() + Price.GroupedTieredPackage.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -5108,25 +4895,24 @@ internal class PriceTest { @Test fun ofMaxGroupTieredPackage() { val maxGroupTieredPackage = - Price.MaxGroupTieredPackagePrice.builder() + Price.MaxGroupTieredPackage.builder() .id("id") .billableMetric( - Price.MaxGroupTieredPackagePrice.BillableMetric.builder().id("id").build() + Price.MaxGroupTieredPackage.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.MaxGroupTieredPackagePrice.BillingCycleConfiguration.builder() + Price.MaxGroupTieredPackage.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MaxGroupTieredPackagePrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.MaxGroupTieredPackage.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.MaxGroupTieredPackagePrice.Cadence.ONE_TIME) + .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.MaxGroupTieredPackagePrice.CreditAllocation.builder() + Price.MaxGroupTieredPackage.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -5144,46 +4930,43 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.MaxGroupTieredPackagePrice.InvoicingCycleConfiguration.builder() + Price.MaxGroupTieredPackage.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MaxGroupTieredPackagePrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + Price.MaxGroupTieredPackage.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.MaxGroupTieredPackagePrice.Item.builder().id("id").name("name").build()) + .item(Price.MaxGroupTieredPackage.Item.builder().id("id").name("name").build()) .maxGroupTieredPackageConfig( - Price.MaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .maximum( - Price.MaxGroupTieredPackagePrice.Maximum.builder() + Price.MaxGroupTieredPackage.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.MaxGroupTieredPackagePrice.Metadata.builder() + Price.MaxGroupTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.MaxGroupTieredPackagePrice.Minimum.builder() + Price.MaxGroupTieredPackage.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.MaxGroupTieredPackagePrice.ModelType.MAX_GROUP_TIERED_PACKAGE) .name("name") .planPhaseOrder(0L) - .priceType(Price.MaxGroupTieredPackagePrice.PriceType.USAGE_PRICE) + .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.MaxGroupTieredPackagePrice.DimensionalPriceConfiguration.builder() + Price.MaxGroupTieredPackage.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -5193,7 +4976,7 @@ internal class PriceTest { val price = Price.ofMaxGroupTieredPackage(maxGroupTieredPackage) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -5227,26 +5010,25 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofMaxGroupTieredPackage( - Price.MaxGroupTieredPackagePrice.builder() + Price.MaxGroupTieredPackage.builder() .id("id") .billableMetric( - Price.MaxGroupTieredPackagePrice.BillableMetric.builder().id("id").build() + Price.MaxGroupTieredPackage.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.MaxGroupTieredPackagePrice.BillingCycleConfiguration.builder() + Price.MaxGroupTieredPackage.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MaxGroupTieredPackagePrice.BillingCycleConfiguration - .DurationUnit + Price.MaxGroupTieredPackage.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.MaxGroupTieredPackagePrice.Cadence.ONE_TIME) + .cadence(Price.MaxGroupTieredPackage.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.MaxGroupTieredPackagePrice.CreditAllocation.builder() + Price.MaxGroupTieredPackage.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -5264,51 +5046,44 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.MaxGroupTieredPackagePrice.InvoicingCycleConfiguration.builder() + Price.MaxGroupTieredPackage.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.MaxGroupTieredPackagePrice.InvoicingCycleConfiguration - .DurationUnit + Price.MaxGroupTieredPackage.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.MaxGroupTieredPackagePrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(Price.MaxGroupTieredPackage.Item.builder().id("id").name("name").build()) .maxGroupTieredPackageConfig( - Price.MaxGroupTieredPackagePrice.MaxGroupTieredPackageConfig.builder() + Price.MaxGroupTieredPackage.MaxGroupTieredPackageConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .maximum( - Price.MaxGroupTieredPackagePrice.Maximum.builder() + Price.MaxGroupTieredPackage.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.MaxGroupTieredPackagePrice.Metadata.builder() + Price.MaxGroupTieredPackage.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.MaxGroupTieredPackagePrice.Minimum.builder() + Price.MaxGroupTieredPackage.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.MaxGroupTieredPackagePrice.ModelType.MAX_GROUP_TIERED_PACKAGE) .name("name") .planPhaseOrder(0L) - .priceType(Price.MaxGroupTieredPackagePrice.PriceType.USAGE_PRICE) + .priceType(Price.MaxGroupTieredPackage.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.MaxGroupTieredPackagePrice.DimensionalPriceConfiguration.builder() + Price.MaxGroupTieredPackage.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -5325,28 +5100,26 @@ internal class PriceTest { @Test fun ofScalableMatrixWithUnitPricing() { val scalableMatrixWithUnitPricing = - Price.ScalableMatrixWithUnitPricingPrice.builder() + Price.ScalableMatrixWithUnitPricing.builder() .id("id") .billableMetric( - Price.ScalableMatrixWithUnitPricingPrice.BillableMetric.builder() - .id("id") - .build() + Price.ScalableMatrixWithUnitPricing.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.ScalableMatrixWithUnitPricingPrice.BillingCycleConfiguration.builder() + Price.ScalableMatrixWithUnitPricing.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ScalableMatrixWithUnitPricingPrice.BillingCycleConfiguration + Price.ScalableMatrixWithUnitPricing.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.ScalableMatrixWithUnitPricingPrice.Cadence.ONE_TIME) + .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.ScalableMatrixWithUnitPricingPrice.CreditAllocation.builder() + Price.ScalableMatrixWithUnitPricing.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -5364,55 +5137,48 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.ScalableMatrixWithUnitPricingPrice.InvoicingCycleConfiguration.builder() + Price.ScalableMatrixWithUnitPricing.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ScalableMatrixWithUnitPricingPrice.InvoicingCycleConfiguration + Price.ScalableMatrixWithUnitPricing.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.ScalableMatrixWithUnitPricingPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.ScalableMatrixWithUnitPricing.Item.builder().id("id").name("name").build() ) .maximum( - Price.ScalableMatrixWithUnitPricingPrice.Maximum.builder() + Price.ScalableMatrixWithUnitPricing.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithUnitPricingPrice.Metadata.builder() + Price.ScalableMatrixWithUnitPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.ScalableMatrixWithUnitPricingPrice.Minimum.builder() + Price.ScalableMatrixWithUnitPricing.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.ScalableMatrixWithUnitPricingPrice.ModelType - .SCALABLE_MATRIX_WITH_UNIT_PRICING - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithUnitPricingPrice.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) .scalableMatrixWithUnitPricingConfig( - Price.ScalableMatrixWithUnitPricingPrice.ScalableMatrixWithUnitPricingConfig + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.ScalableMatrixWithUnitPricingPrice.DimensionalPriceConfiguration.builder() + Price.ScalableMatrixWithUnitPricing.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -5422,7 +5188,7 @@ internal class PriceTest { val price = Price.ofScalableMatrixWithUnitPricing(scalableMatrixWithUnitPricing) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -5456,28 +5222,28 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofScalableMatrixWithUnitPricing( - Price.ScalableMatrixWithUnitPricingPrice.builder() + Price.ScalableMatrixWithUnitPricing.builder() .id("id") .billableMetric( - Price.ScalableMatrixWithUnitPricingPrice.BillableMetric.builder() + Price.ScalableMatrixWithUnitPricing.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.ScalableMatrixWithUnitPricingPrice.BillingCycleConfiguration.builder() + Price.ScalableMatrixWithUnitPricing.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ScalableMatrixWithUnitPricingPrice.BillingCycleConfiguration + Price.ScalableMatrixWithUnitPricing.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.ScalableMatrixWithUnitPricingPrice.Cadence.ONE_TIME) + .cadence(Price.ScalableMatrixWithUnitPricing.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.ScalableMatrixWithUnitPricingPrice.CreditAllocation.builder() + Price.ScalableMatrixWithUnitPricing.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -5495,57 +5261,51 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.ScalableMatrixWithUnitPricingPrice.InvoicingCycleConfiguration - .builder() + Price.ScalableMatrixWithUnitPricing.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ScalableMatrixWithUnitPricingPrice.InvoicingCycleConfiguration + Price.ScalableMatrixWithUnitPricing.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.ScalableMatrixWithUnitPricingPrice.Item.builder() + Price.ScalableMatrixWithUnitPricing.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.ScalableMatrixWithUnitPricingPrice.Maximum.builder() + Price.ScalableMatrixWithUnitPricing.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithUnitPricingPrice.Metadata.builder() + Price.ScalableMatrixWithUnitPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.ScalableMatrixWithUnitPricingPrice.Minimum.builder() + Price.ScalableMatrixWithUnitPricing.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.ScalableMatrixWithUnitPricingPrice.ModelType - .SCALABLE_MATRIX_WITH_UNIT_PRICING - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithUnitPricingPrice.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithUnitPricing.PriceType.USAGE_PRICE) .scalableMatrixWithUnitPricingConfig( - Price.ScalableMatrixWithUnitPricingPrice.ScalableMatrixWithUnitPricingConfig + Price.ScalableMatrixWithUnitPricing.ScalableMatrixWithUnitPricingConfig .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.ScalableMatrixWithUnitPricingPrice.DimensionalPriceConfiguration - .builder() + Price.ScalableMatrixWithUnitPricing.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -5562,28 +5322,26 @@ internal class PriceTest { @Test fun ofScalableMatrixWithTieredPricing() { val scalableMatrixWithTieredPricing = - Price.ScalableMatrixWithTieredPricingPrice.builder() + Price.ScalableMatrixWithTieredPricing.builder() .id("id") .billableMetric( - Price.ScalableMatrixWithTieredPricingPrice.BillableMetric.builder() - .id("id") - .build() + Price.ScalableMatrixWithTieredPricing.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.ScalableMatrixWithTieredPricingPrice.BillingCycleConfiguration.builder() + Price.ScalableMatrixWithTieredPricing.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ScalableMatrixWithTieredPricingPrice.BillingCycleConfiguration + Price.ScalableMatrixWithTieredPricing.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.ScalableMatrixWithTieredPricingPrice.Cadence.ONE_TIME) + .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.ScalableMatrixWithTieredPricingPrice.CreditAllocation.builder() + Price.ScalableMatrixWithTieredPricing.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -5601,56 +5359,51 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.ScalableMatrixWithTieredPricingPrice.InvoicingCycleConfiguration.builder() + Price.ScalableMatrixWithTieredPricing.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ScalableMatrixWithTieredPricingPrice.InvoicingCycleConfiguration + Price.ScalableMatrixWithTieredPricing.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.ScalableMatrixWithTieredPricingPrice.Item.builder() + Price.ScalableMatrixWithTieredPricing.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.ScalableMatrixWithTieredPricingPrice.Maximum.builder() + Price.ScalableMatrixWithTieredPricing.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithTieredPricingPrice.Metadata.builder() + Price.ScalableMatrixWithTieredPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.ScalableMatrixWithTieredPricingPrice.Minimum.builder() + Price.ScalableMatrixWithTieredPricing.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.ScalableMatrixWithTieredPricingPrice.ModelType - .SCALABLE_MATRIX_WITH_TIERED_PRICING - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithTieredPricingPrice.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) .scalableMatrixWithTieredPricingConfig( - Price.ScalableMatrixWithTieredPricingPrice.ScalableMatrixWithTieredPricingConfig + Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.ScalableMatrixWithTieredPricingPrice.DimensionalPriceConfiguration - .builder() + Price.ScalableMatrixWithTieredPricing.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -5660,7 +5413,7 @@ internal class PriceTest { val price = Price.ofScalableMatrixWithTieredPricing(scalableMatrixWithTieredPricing) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -5695,29 +5448,28 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofScalableMatrixWithTieredPricing( - Price.ScalableMatrixWithTieredPricingPrice.builder() + Price.ScalableMatrixWithTieredPricing.builder() .id("id") .billableMetric( - Price.ScalableMatrixWithTieredPricingPrice.BillableMetric.builder() + Price.ScalableMatrixWithTieredPricing.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.ScalableMatrixWithTieredPricingPrice.BillingCycleConfiguration - .builder() + Price.ScalableMatrixWithTieredPricing.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ScalableMatrixWithTieredPricingPrice.BillingCycleConfiguration + Price.ScalableMatrixWithTieredPricing.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.ScalableMatrixWithTieredPricingPrice.Cadence.ONE_TIME) + .cadence(Price.ScalableMatrixWithTieredPricing.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.ScalableMatrixWithTieredPricingPrice.CreditAllocation.builder() + Price.ScalableMatrixWithTieredPricing.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -5735,58 +5487,51 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.ScalableMatrixWithTieredPricingPrice.InvoicingCycleConfiguration - .builder() + Price.ScalableMatrixWithTieredPricing.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.ScalableMatrixWithTieredPricingPrice - .InvoicingCycleConfiguration + Price.ScalableMatrixWithTieredPricing.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.ScalableMatrixWithTieredPricingPrice.Item.builder() + Price.ScalableMatrixWithTieredPricing.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.ScalableMatrixWithTieredPricingPrice.Maximum.builder() + Price.ScalableMatrixWithTieredPricing.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.ScalableMatrixWithTieredPricingPrice.Metadata.builder() + Price.ScalableMatrixWithTieredPricing.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.ScalableMatrixWithTieredPricingPrice.Minimum.builder() + Price.ScalableMatrixWithTieredPricing.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType( - Price.ScalableMatrixWithTieredPricingPrice.ModelType - .SCALABLE_MATRIX_WITH_TIERED_PRICING - ) .name("name") .planPhaseOrder(0L) - .priceType(Price.ScalableMatrixWithTieredPricingPrice.PriceType.USAGE_PRICE) + .priceType(Price.ScalableMatrixWithTieredPricing.PriceType.USAGE_PRICE) .scalableMatrixWithTieredPricingConfig( - Price.ScalableMatrixWithTieredPricingPrice - .ScalableMatrixWithTieredPricingConfig + Price.ScalableMatrixWithTieredPricing.ScalableMatrixWithTieredPricingConfig .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .dimensionalPriceConfiguration( - Price.ScalableMatrixWithTieredPricingPrice.DimensionalPriceConfiguration + Price.ScalableMatrixWithTieredPricing.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") @@ -5804,31 +5549,30 @@ internal class PriceTest { @Test fun ofCumulativeGroupedBulk() { val cumulativeGroupedBulk = - Price.CumulativeGroupedBulkPrice.builder() + Price.CumulativeGroupedBulk.builder() .id("id") .billableMetric( - Price.CumulativeGroupedBulkPrice.BillableMetric.builder().id("id").build() + Price.CumulativeGroupedBulk.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.CumulativeGroupedBulkPrice.BillingCycleConfiguration.builder() + Price.CumulativeGroupedBulk.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.CumulativeGroupedBulkPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.CumulativeGroupedBulk.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.CumulativeGroupedBulkPrice.Cadence.ONE_TIME) + .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.CumulativeGroupedBulkPrice.CreditAllocation.builder() + Price.CumulativeGroupedBulk.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() ) .cumulativeGroupedBulkConfig( - Price.CumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -5845,41 +5589,38 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.CumulativeGroupedBulkPrice.InvoicingCycleConfiguration.builder() + Price.CumulativeGroupedBulk.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.CumulativeGroupedBulkPrice.InvoicingCycleConfiguration - .DurationUnit - .DAY + Price.CumulativeGroupedBulk.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.CumulativeGroupedBulkPrice.Item.builder().id("id").name("name").build()) + .item(Price.CumulativeGroupedBulk.Item.builder().id("id").name("name").build()) .maximum( - Price.CumulativeGroupedBulkPrice.Maximum.builder() + Price.CumulativeGroupedBulk.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedBulkPrice.Metadata.builder() + Price.CumulativeGroupedBulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.CumulativeGroupedBulkPrice.Minimum.builder() + Price.CumulativeGroupedBulk.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.CumulativeGroupedBulkPrice.ModelType.CUMULATIVE_GROUPED_BULK) .name("name") .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedBulkPrice.PriceType.USAGE_PRICE) + .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.CumulativeGroupedBulkPrice.DimensionalPriceConfiguration.builder() + Price.CumulativeGroupedBulk.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -5889,7 +5630,7 @@ internal class PriceTest { val price = Price.ofCumulativeGroupedBulk(cumulativeGroupedBulk) assertThat(price.unit()).isEmpty - assertThat(price.packagePrice()).isEmpty + assertThat(price.package_()).isEmpty assertThat(price.matrix()).isEmpty assertThat(price.tiered()).isEmpty assertThat(price.tieredBps()).isEmpty @@ -5923,32 +5664,31 @@ internal class PriceTest { val jsonMapper = jsonMapper() val price = Price.ofCumulativeGroupedBulk( - Price.CumulativeGroupedBulkPrice.builder() + Price.CumulativeGroupedBulk.builder() .id("id") .billableMetric( - Price.CumulativeGroupedBulkPrice.BillableMetric.builder().id("id").build() + Price.CumulativeGroupedBulk.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.CumulativeGroupedBulkPrice.BillingCycleConfiguration.builder() + Price.CumulativeGroupedBulk.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.CumulativeGroupedBulkPrice.BillingCycleConfiguration - .DurationUnit + Price.CumulativeGroupedBulk.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.CumulativeGroupedBulkPrice.Cadence.ONE_TIME) + .cadence(Price.CumulativeGroupedBulk.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.CumulativeGroupedBulkPrice.CreditAllocation.builder() + Price.CumulativeGroupedBulk.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() ) .cumulativeGroupedBulkConfig( - Price.CumulativeGroupedBulkPrice.CumulativeGroupedBulkConfig.builder() + Price.CumulativeGroupedBulk.CumulativeGroupedBulkConfig.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -5965,46 +5705,39 @@ internal class PriceTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.CumulativeGroupedBulkPrice.InvoicingCycleConfiguration.builder() + Price.CumulativeGroupedBulk.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.CumulativeGroupedBulkPrice.InvoicingCycleConfiguration - .DurationUnit + Price.CumulativeGroupedBulk.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.CumulativeGroupedBulkPrice.Item.builder() - .id("id") - .name("name") - .build() - ) + .item(Price.CumulativeGroupedBulk.Item.builder().id("id").name("name").build()) .maximum( - Price.CumulativeGroupedBulkPrice.Maximum.builder() + Price.CumulativeGroupedBulk.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.CumulativeGroupedBulkPrice.Metadata.builder() + Price.CumulativeGroupedBulk.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.CumulativeGroupedBulkPrice.Minimum.builder() + Price.CumulativeGroupedBulk.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.CumulativeGroupedBulkPrice.ModelType.CUMULATIVE_GROUPED_BULK) .name("name") .planPhaseOrder(0L) - .priceType(Price.CumulativeGroupedBulkPrice.PriceType.USAGE_PRICE) + .priceType(Price.CumulativeGroupedBulk.PriceType.USAGE_PRICE) .dimensionalPriceConfiguration( - Price.CumulativeGroupedBulkPrice.DimensionalPriceConfiguration.builder() + Price.CumulativeGroupedBulk.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt index 1bf45e53..cc97d97b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCancelResponseTest.kt @@ -21,16 +21,9 @@ internal class SubscriptionCancelResponseTest { SubscriptionCancelResponse.AdjustmentInterval.builder() .id("id") .adjustment( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + SubscriptionCancelResponse.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -143,15 +136,10 @@ internal class SubscriptionCancelResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval.builder() + SubscriptionCancelResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -197,12 +185,8 @@ internal class SubscriptionCancelResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -288,25 +272,24 @@ internal class SubscriptionCancelResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -324,45 +307,43 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -407,25 +388,24 @@ internal class SubscriptionCancelResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -443,45 +423,43 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -699,16 +677,8 @@ internal class SubscriptionCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -749,32 +719,30 @@ internal class SubscriptionCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -795,32 +763,30 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -828,23 +794,22 @@ internal class SubscriptionCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -859,30 +824,23 @@ internal class SubscriptionCancelResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1144,16 +1102,8 @@ internal class SubscriptionCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1194,32 +1144,30 @@ internal class SubscriptionCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1240,32 +1188,30 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1273,23 +1219,22 @@ internal class SubscriptionCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1304,30 +1249,23 @@ internal class SubscriptionCancelResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1409,16 +1347,9 @@ internal class SubscriptionCancelResponseTest { SubscriptionCancelResponse.AdjustmentInterval.builder() .id("id") .adjustment( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + SubscriptionCancelResponse.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1537,15 +1468,10 @@ internal class SubscriptionCancelResponseTest { assertThat(subscriptionCancelResponse.discountIntervals()) .containsExactly( SubscriptionCancelResponse.DiscountInterval.ofAmount( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval.builder() + SubscriptionCancelResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1599,12 +1525,8 @@ internal class SubscriptionCancelResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1690,24 +1612,22 @@ internal class SubscriptionCancelResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1725,44 +1645,41 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1804,24 +1721,22 @@ internal class SubscriptionCancelResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1839,44 +1754,41 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2090,15 +2002,8 @@ internal class SubscriptionCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2139,30 +2044,28 @@ internal class SubscriptionCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2182,31 +2085,30 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2214,24 +2116,22 @@ internal class SubscriptionCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2243,29 +2143,23 @@ internal class SubscriptionCancelResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2516,15 +2410,8 @@ internal class SubscriptionCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2565,30 +2452,28 @@ internal class SubscriptionCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2608,31 +2493,30 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2640,24 +2524,22 @@ internal class SubscriptionCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2669,29 +2551,23 @@ internal class SubscriptionCancelResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2775,16 +2651,9 @@ internal class SubscriptionCancelResponseTest { SubscriptionCancelResponse.AdjustmentInterval.builder() .id("id") .adjustment( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + SubscriptionCancelResponse.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionCancelResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2897,15 +2766,10 @@ internal class SubscriptionCancelResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval.builder() + SubscriptionCancelResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCancelResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -2951,12 +2815,8 @@ internal class SubscriptionCancelResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3042,25 +2902,24 @@ internal class SubscriptionCancelResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3078,45 +2937,43 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3161,25 +3018,24 @@ internal class SubscriptionCancelResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3197,45 +3053,43 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3453,16 +3307,8 @@ internal class SubscriptionCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3503,32 +3349,30 @@ internal class SubscriptionCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3549,32 +3393,30 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3582,23 +3424,22 @@ internal class SubscriptionCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3613,30 +3454,23 @@ internal class SubscriptionCancelResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3898,16 +3732,8 @@ internal class SubscriptionCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3948,32 +3774,30 @@ internal class SubscriptionCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3994,32 +3818,30 @@ internal class SubscriptionCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4027,23 +3849,22 @@ internal class SubscriptionCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4058,30 +3879,23 @@ internal class SubscriptionCancelResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") 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 28d0ad07..68d268cd 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 @@ -29,17 +29,9 @@ internal class SubscriptionChangeApplyResponseTest { .adjustment( SubscriptionChangeApplyResponse.Subscription.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionChangeApplyResponse.Subscription - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -159,18 +151,11 @@ internal class SubscriptionChangeApplyResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionChangeApplyResponse.Subscription.DiscountInterval - .AmountDiscountInterval + SubscriptionChangeApplyResponse.Subscription.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionChangeApplyResponse.Subscription.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -220,13 +205,8 @@ internal class SubscriptionChangeApplyResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -314,28 +294,26 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -355,30 +333,27 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -386,23 +361,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -452,28 +426,26 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -493,30 +465,27 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -524,23 +493,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -784,16 +752,9 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -839,27 +800,26 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -867,8 +827,7 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -893,12 +852,11 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -906,20 +864,20 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -927,26 +885,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -963,12 +917,10 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -976,8 +928,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -985,12 +936,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1291,16 +1236,9 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1346,27 +1284,26 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -1374,8 +1311,7 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1400,12 +1336,11 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -1413,20 +1348,20 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1434,26 +1369,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1470,12 +1401,10 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -1483,8 +1412,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -1492,12 +1420,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1607,17 +1529,9 @@ internal class SubscriptionChangeApplyResponseTest { .adjustment( SubscriptionChangeApplyResponse.Subscription.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionChangeApplyResponse.Subscription - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1732,18 +1646,11 @@ internal class SubscriptionChangeApplyResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionChangeApplyResponse.Subscription.DiscountInterval - .AmountDiscountInterval + SubscriptionChangeApplyResponse.Subscription.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionChangeApplyResponse.Subscription.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1793,13 +1700,8 @@ internal class SubscriptionChangeApplyResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1887,26 +1789,25 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1926,48 +1827,44 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2013,26 +1910,25 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2052,48 +1948,44 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2320,16 +2212,8 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2372,26 +2256,25 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -2399,7 +2282,7 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2420,11 +2303,11 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -2432,20 +2315,20 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2453,26 +2336,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -2487,21 +2366,17 @@ internal class SubscriptionChangeApplyResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -2509,12 +2384,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2795,16 +2664,8 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2847,26 +2708,25 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -2874,7 +2734,7 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2895,11 +2755,11 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -2907,20 +2767,20 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2928,26 +2788,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -2962,21 +2818,17 @@ internal class SubscriptionChangeApplyResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -2984,12 +2836,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3099,17 +2945,9 @@ internal class SubscriptionChangeApplyResponseTest { .adjustment( SubscriptionChangeApplyResponse.Subscription.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionChangeApplyResponse.Subscription - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3229,18 +3067,11 @@ internal class SubscriptionChangeApplyResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionChangeApplyResponse.Subscription.DiscountInterval - .AmountDiscountInterval + SubscriptionChangeApplyResponse.Subscription.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionChangeApplyResponse.Subscription.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -3290,13 +3121,8 @@ internal class SubscriptionChangeApplyResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3384,28 +3210,26 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3425,30 +3249,27 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3456,23 +3277,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -3522,28 +3342,26 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3563,30 +3381,27 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3594,23 +3409,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -3854,16 +3668,9 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3909,27 +3716,26 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -3937,8 +3743,7 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3963,12 +3768,11 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -3976,20 +3780,20 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3997,26 +3801,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4033,12 +3833,10 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -4046,8 +3844,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -4055,12 +3852,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -4361,16 +4152,9 @@ internal class SubscriptionChangeApplyResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -4416,27 +4200,26 @@ internal class SubscriptionChangeApplyResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -4444,8 +4227,7 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4470,12 +4252,11 @@ internal class SubscriptionChangeApplyResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -4483,20 +4264,20 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4504,26 +4285,22 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4540,12 +4317,10 @@ internal class SubscriptionChangeApplyResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -4553,8 +4328,7 @@ internal class SubscriptionChangeApplyResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -4562,12 +4336,6 @@ internal class SubscriptionChangeApplyResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") 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 d140d9eb..4836f292 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 @@ -29,17 +29,9 @@ internal class SubscriptionChangeCancelResponseTest { .adjustment( SubscriptionChangeCancelResponse.Subscription.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionChangeCancelResponse.Subscription - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -159,18 +151,11 @@ internal class SubscriptionChangeCancelResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionChangeCancelResponse.Subscription.DiscountInterval - .AmountDiscountInterval + SubscriptionChangeCancelResponse.Subscription.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionChangeCancelResponse.Subscription.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -220,13 +205,8 @@ internal class SubscriptionChangeCancelResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -314,28 +294,26 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -355,30 +333,27 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -386,23 +361,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -452,28 +426,26 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -493,30 +465,27 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -524,23 +493,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -784,16 +752,9 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -839,27 +800,26 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -867,8 +827,7 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -893,12 +852,11 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -906,20 +864,20 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -927,26 +885,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -963,12 +917,10 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -976,8 +928,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -985,12 +936,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1291,16 +1236,9 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1346,27 +1284,26 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -1374,8 +1311,7 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1400,12 +1336,11 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -1413,20 +1348,20 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1434,26 +1369,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1470,12 +1401,10 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -1483,8 +1412,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -1492,12 +1420,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1607,17 +1529,9 @@ internal class SubscriptionChangeCancelResponseTest { .adjustment( SubscriptionChangeCancelResponse.Subscription.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionChangeCancelResponse.Subscription - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1733,18 +1647,11 @@ internal class SubscriptionChangeCancelResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionChangeCancelResponse.Subscription.DiscountInterval - .AmountDiscountInterval + SubscriptionChangeCancelResponse.Subscription.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionChangeCancelResponse.Subscription.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1794,13 +1701,8 @@ internal class SubscriptionChangeCancelResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1888,26 +1790,25 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1927,48 +1828,44 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2014,26 +1911,25 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2053,48 +1949,44 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2321,16 +2213,8 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2373,26 +2257,25 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -2400,7 +2283,7 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2421,11 +2304,11 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -2433,20 +2316,20 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2454,26 +2337,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -2488,21 +2367,17 @@ internal class SubscriptionChangeCancelResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -2510,12 +2385,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2796,16 +2665,8 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2848,26 +2709,25 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -2875,7 +2735,7 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2896,11 +2756,11 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -2908,20 +2768,20 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2929,26 +2789,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -2963,21 +2819,17 @@ internal class SubscriptionChangeCancelResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -2985,12 +2837,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3100,17 +2946,9 @@ internal class SubscriptionChangeCancelResponseTest { .adjustment( SubscriptionChangeCancelResponse.Subscription.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionChangeCancelResponse.Subscription - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3230,18 +3068,11 @@ internal class SubscriptionChangeCancelResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionChangeCancelResponse.Subscription.DiscountInterval - .AmountDiscountInterval + SubscriptionChangeCancelResponse.Subscription.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionChangeCancelResponse.Subscription.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -3291,13 +3122,8 @@ internal class SubscriptionChangeCancelResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3385,28 +3211,26 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3426,30 +3250,27 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3457,23 +3278,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -3523,28 +3343,26 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3564,30 +3382,27 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3595,23 +3410,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -3855,16 +3669,9 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3910,27 +3717,26 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -3938,8 +3744,7 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3964,12 +3769,11 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -3977,20 +3781,20 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3998,26 +3802,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4034,12 +3834,10 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -4047,8 +3845,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -4056,12 +3853,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -4362,16 +4153,9 @@ internal class SubscriptionChangeCancelResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -4417,27 +4201,26 @@ internal class SubscriptionChangeCancelResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -4445,8 +4228,7 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4471,12 +4253,11 @@ internal class SubscriptionChangeCancelResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -4484,20 +4265,20 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4505,26 +4286,22 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4541,12 +4318,10 @@ internal class SubscriptionChangeCancelResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -4554,8 +4329,7 @@ internal class SubscriptionChangeCancelResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -4563,12 +4337,6 @@ internal class SubscriptionChangeCancelResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") 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 c3209a16..5f8c766d 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 @@ -30,17 +30,9 @@ internal class SubscriptionChangeRetrieveResponseTest { SubscriptionChangeRetrieveResponse.Subscription .AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionChangeRetrieveResponse.Subscription - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -160,18 +152,11 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval - .AmountDiscountInterval + SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -224,13 +209,8 @@ internal class SubscriptionChangeRetrieveResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -318,28 +298,26 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -359,30 +337,27 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -390,23 +365,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -456,28 +430,26 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -497,30 +469,27 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -528,23 +497,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -789,16 +757,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -844,27 +805,26 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -872,8 +832,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -898,12 +857,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -911,20 +869,20 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -932,26 +890,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -968,12 +922,10 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -981,8 +933,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -990,12 +941,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1296,16 +1241,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1351,27 +1289,26 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -1379,8 +1316,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1405,12 +1341,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -1418,20 +1353,20 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1439,26 +1374,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1475,12 +1406,10 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -1488,8 +1417,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -1497,12 +1425,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1612,17 +1534,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .adjustment( SubscriptionChangeRetrieveResponse.Subscription.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionChangeRetrieveResponse.Subscription - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1738,18 +1652,11 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval - .AmountDiscountInterval + SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1799,13 +1706,8 @@ internal class SubscriptionChangeRetrieveResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1893,26 +1795,25 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1932,48 +1833,44 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2019,26 +1916,25 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2058,48 +1954,44 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2326,16 +2218,8 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2378,26 +2262,25 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -2405,7 +2288,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2426,11 +2309,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -2438,20 +2321,20 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2459,26 +2342,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -2493,21 +2372,17 @@ internal class SubscriptionChangeRetrieveResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -2515,12 +2390,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2801,16 +2670,8 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2853,26 +2714,25 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -2880,7 +2740,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2901,11 +2761,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -2913,20 +2773,20 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2934,26 +2794,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -2968,21 +2824,17 @@ internal class SubscriptionChangeRetrieveResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -2990,12 +2842,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3106,17 +2952,9 @@ internal class SubscriptionChangeRetrieveResponseTest { SubscriptionChangeRetrieveResponse.Subscription .AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionChangeRetrieveResponse.Subscription - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3236,18 +3074,11 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval - .AmountDiscountInterval + SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionChangeRetrieveResponse.Subscription.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -3300,13 +3131,8 @@ internal class SubscriptionChangeRetrieveResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3394,28 +3220,26 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3435,30 +3259,27 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3466,23 +3287,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -3532,28 +3352,26 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3573,30 +3391,27 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3604,23 +3419,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -3865,16 +3679,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3920,27 +3727,26 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -3948,8 +3754,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3974,12 +3779,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -3987,20 +3791,20 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4008,26 +3812,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4044,12 +3844,10 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -4057,8 +3855,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -4066,12 +3863,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -4372,16 +4163,9 @@ internal class SubscriptionChangeRetrieveResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment + Invoice.LineItem.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -4427,27 +4211,26 @@ internal class SubscriptionChangeRetrieveResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse( @@ -4455,8 +4238,7 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .creditAllocation( - Price.UnitPrice.CreditAllocation - .builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4481,12 +4263,11 @@ internal class SubscriptionChangeRetrieveResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - Price.UnitPrice + Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -4494,20 +4275,20 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4515,26 +4296,22 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType( - Price.UnitPrice.PriceType.USAGE_PRICE - ) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice - .DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4551,12 +4328,10 @@ internal class SubscriptionChangeRetrieveResponseTest { ) ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .Grouping .builder() .key("region") @@ -4564,8 +4339,7 @@ internal class SubscriptionChangeRetrieveResponseTest { .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem + Invoice.LineItem.SubLineItem.Matrix .MatrixConfig .builder() .addDimensionValue("string") @@ -4573,12 +4347,6 @@ internal class SubscriptionChangeRetrieveResponseTest { ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem - .MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt index bcbca74b..c6e5a87a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateParamsTest.kt @@ -16,14 +16,8 @@ internal class SubscriptionCreateParamsTest { .addAddAdjustment( SubscriptionCreateParams.AddAdjustment.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment.NewPercentageDiscount + SubscriptionCreateParams.AddAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -63,36 +57,24 @@ internal class SubscriptionCreateParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice.builder() - .cadence( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Cadence - .ANNUAL - ) + SubscriptionCreateParams.AddPrice.Price.Unit.builder() + .cadence(SubscriptionCreateParams.AddPrice.Price.Unit.Cadence.ANNUAL) .itemId("item_id") - .modelType( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .UnitConfig - .builder() + SubscriptionCreateParams.AddPrice.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -105,13 +87,12 @@ internal class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -119,9 +100,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Metadata - .builder() + SubscriptionCreateParams.AddPrice.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -178,14 +157,8 @@ internal class SubscriptionCreateParamsTest { .addReplaceAdjustment( SubscriptionCreateParams.ReplaceAdjustment.builder() .adjustment( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment.NewPercentageDiscount + SubscriptionCreateParams.ReplaceAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -225,23 +198,14 @@ internal class SubscriptionCreateParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionCreateParams.ReplacePrice.Price.Unit.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .Cadence - .ANNUAL + SubscriptionCreateParams.ReplacePrice.Price.Unit.Cadence.ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .UnitConfig + SubscriptionCreateParams.ReplacePrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -249,13 +213,12 @@ internal class SubscriptionCreateParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -268,13 +231,12 @@ internal class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -282,9 +244,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .Metadata - .builder() + SubscriptionCreateParams.ReplacePrice.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -307,14 +267,8 @@ internal class SubscriptionCreateParamsTest { .addAddAdjustment( SubscriptionCreateParams.AddAdjustment.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment.NewPercentageDiscount + SubscriptionCreateParams.AddAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -356,23 +310,14 @@ internal class SubscriptionCreateParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionCreateParams.AddPrice.Price.Unit.builder() .cadence( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Cadence - .ANNUAL + SubscriptionCreateParams.AddPrice.Price.Unit.Cadence.ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .UnitConfig + SubscriptionCreateParams.AddPrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -380,13 +325,12 @@ internal class SubscriptionCreateParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -399,13 +343,12 @@ internal class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -413,9 +356,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Metadata - .builder() + SubscriptionCreateParams.AddPrice.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -472,15 +413,8 @@ internal class SubscriptionCreateParamsTest { .addReplaceAdjustment( SubscriptionCreateParams.ReplaceAdjustment.builder() .adjustment( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount + SubscriptionCreateParams.ReplaceAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -520,26 +454,14 @@ internal class SubscriptionCreateParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionCreateParams.ReplacePrice.Price.Unit.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence - .ANNUAL + SubscriptionCreateParams.ReplacePrice.Price.Unit.Cadence.ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig + SubscriptionCreateParams.ReplacePrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -547,14 +469,12 @@ internal class SubscriptionCreateParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -567,14 +487,12 @@ internal class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -582,9 +500,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + SubscriptionCreateParams.ReplacePrice.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -606,14 +522,8 @@ internal class SubscriptionCreateParamsTest { .containsExactly( SubscriptionCreateParams.AddAdjustment.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment.NewPercentageDiscount + SubscriptionCreateParams.AddAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -654,36 +564,24 @@ internal class SubscriptionCreateParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice.builder() - .cadence( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Cadence - .ANNUAL - ) + SubscriptionCreateParams.AddPrice.Price.Unit.builder() + .cadence(SubscriptionCreateParams.AddPrice.Price.Unit.Cadence.ANNUAL) .itemId("item_id") - .modelType( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .UnitConfig - .builder() + SubscriptionCreateParams.AddPrice.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -696,13 +594,12 @@ internal class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -710,9 +607,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .Metadata - .builder() + SubscriptionCreateParams.AddPrice.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -777,14 +672,8 @@ internal class SubscriptionCreateParamsTest { .containsExactly( SubscriptionCreateParams.ReplaceAdjustment.builder() .adjustment( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment.NewPercentageDiscount + SubscriptionCreateParams.ReplaceAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -825,23 +714,14 @@ internal class SubscriptionCreateParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionCreateParams.ReplacePrice.Price.Unit.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .Cadence - .ANNUAL + SubscriptionCreateParams.ReplacePrice.Price.Unit.Cadence.ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .UnitConfig + SubscriptionCreateParams.ReplacePrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -849,13 +729,12 @@ internal class SubscriptionCreateParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -868,13 +747,12 @@ internal class SubscriptionCreateParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -882,9 +760,7 @@ internal class SubscriptionCreateParamsTest { .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .Metadata - .builder() + SubscriptionCreateParams.ReplacePrice.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt index ecec5b7f..4e9818f5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionCreateResponseTest.kt @@ -21,16 +21,9 @@ internal class SubscriptionCreateResponseTest { SubscriptionCreateResponse.AdjustmentInterval.builder() .id("id") .adjustment( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + SubscriptionCreateResponse.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -143,15 +136,10 @@ internal class SubscriptionCreateResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval.builder() + SubscriptionCreateResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -197,12 +185,8 @@ internal class SubscriptionCreateResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -288,25 +272,24 @@ internal class SubscriptionCreateResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -324,45 +307,43 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -407,25 +388,24 @@ internal class SubscriptionCreateResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -443,45 +423,43 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -699,16 +677,8 @@ internal class SubscriptionCreateResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -749,32 +719,30 @@ internal class SubscriptionCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -795,32 +763,30 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -828,23 +794,22 @@ internal class SubscriptionCreateResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -859,30 +824,23 @@ internal class SubscriptionCreateResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1144,16 +1102,8 @@ internal class SubscriptionCreateResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1194,32 +1144,30 @@ internal class SubscriptionCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1240,32 +1188,30 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1273,23 +1219,22 @@ internal class SubscriptionCreateResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1304,30 +1249,23 @@ internal class SubscriptionCreateResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1409,16 +1347,9 @@ internal class SubscriptionCreateResponseTest { SubscriptionCreateResponse.AdjustmentInterval.builder() .id("id") .adjustment( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + SubscriptionCreateResponse.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1537,15 +1468,10 @@ internal class SubscriptionCreateResponseTest { assertThat(subscriptionCreateResponse.discountIntervals()) .containsExactly( SubscriptionCreateResponse.DiscountInterval.ofAmount( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval.builder() + SubscriptionCreateResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1599,12 +1525,8 @@ internal class SubscriptionCreateResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1690,24 +1612,22 @@ internal class SubscriptionCreateResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1725,44 +1645,41 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1804,24 +1721,22 @@ internal class SubscriptionCreateResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1839,44 +1754,41 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2090,15 +2002,8 @@ internal class SubscriptionCreateResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2139,30 +2044,28 @@ internal class SubscriptionCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2182,31 +2085,30 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2214,24 +2116,22 @@ internal class SubscriptionCreateResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2243,29 +2143,23 @@ internal class SubscriptionCreateResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2516,15 +2410,8 @@ internal class SubscriptionCreateResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2565,30 +2452,28 @@ internal class SubscriptionCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2608,31 +2493,30 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2640,24 +2524,22 @@ internal class SubscriptionCreateResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2669,29 +2551,23 @@ internal class SubscriptionCreateResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2775,16 +2651,9 @@ internal class SubscriptionCreateResponseTest { SubscriptionCreateResponse.AdjustmentInterval.builder() .id("id") .adjustment( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + SubscriptionCreateResponse.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionCreateResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2897,15 +2766,10 @@ internal class SubscriptionCreateResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval.builder() + SubscriptionCreateResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionCreateResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -2951,12 +2815,8 @@ internal class SubscriptionCreateResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3042,25 +2902,24 @@ internal class SubscriptionCreateResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3078,45 +2937,43 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3161,25 +3018,24 @@ internal class SubscriptionCreateResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3197,45 +3053,43 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3453,16 +3307,8 @@ internal class SubscriptionCreateResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3503,32 +3349,30 @@ internal class SubscriptionCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3549,32 +3393,30 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3582,23 +3424,22 @@ internal class SubscriptionCreateResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3613,30 +3454,23 @@ internal class SubscriptionCreateResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3898,16 +3732,8 @@ internal class SubscriptionCreateResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3948,32 +3774,30 @@ internal class SubscriptionCreateResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3994,32 +3818,30 @@ internal class SubscriptionCreateResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4027,23 +3849,22 @@ internal class SubscriptionCreateResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4058,30 +3879,23 @@ internal class SubscriptionCreateResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") 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 1197b4f4..9be91a3b 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 @@ -20,28 +20,26 @@ internal class SubscriptionFetchCostsResponseTest { .addPerPriceCost( SubscriptionFetchCostsResponse.Data.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -61,30 +59,27 @@ internal class SubscriptionFetchCostsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -92,23 +87,22 @@ internal class SubscriptionFetchCostsResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -137,26 +131,25 @@ internal class SubscriptionFetchCostsResponseTest { .addPerPriceCost( SubscriptionFetchCostsResponse.Data.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -176,48 +169,44 @@ internal class SubscriptionFetchCostsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -248,28 +237,26 @@ internal class SubscriptionFetchCostsResponseTest { .addPerPriceCost( SubscriptionFetchCostsResponse.Data.PerPriceCost.builder() .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -289,30 +276,27 @@ internal class SubscriptionFetchCostsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -320,23 +304,22 @@ internal class SubscriptionFetchCostsResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" 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 15c247f2..54ca0abb 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 @@ -27,7 +27,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .expiresAtEndOfCadence(true) .build() ) - .addAmountDiscountCreationParamsDiscount(0.0) + .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") @@ -40,37 +40,25 @@ internal class SubscriptionPriceIntervalsParamsTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice.builder() - .cadence( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Cadence - .ANNUAL - ) + SubscriptionPriceIntervalsParams.Add.Price.Unit.builder() + .cadence(SubscriptionPriceIntervalsParams.Add.Price.Unit.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .UnitConfig - .builder() + SubscriptionPriceIntervalsParams.Add.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -82,13 +70,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -96,9 +83,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Metadata - .builder() + SubscriptionPriceIntervalsParams.Add.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -111,15 +96,8 @@ internal class SubscriptionPriceIntervalsParamsTest { .addAddAdjustment( SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount + SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -186,7 +164,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .expiresAtEndOfCadence(true) .build() ) - .addAmountDiscountCreationParamsDiscount(0.0) + .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") @@ -200,24 +178,15 @@ internal class SubscriptionPriceIntervalsParamsTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .builder() + SubscriptionPriceIntervalsParams.Add.Price.Unit.builder() .cadence( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Cadence - .ANNUAL + SubscriptionPriceIntervalsParams.Add.Price.Unit.Cadence.ANNUAL ) .currency("currency") .itemId("item_id") - .modelType( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .UnitConfig + SubscriptionPriceIntervalsParams.Add.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -225,13 +194,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -243,13 +211,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -257,8 +224,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Metadata + SubscriptionPriceIntervalsParams.Add.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -273,14 +239,8 @@ internal class SubscriptionPriceIntervalsParamsTest { SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -334,7 +294,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .expiresAtEndOfCadence(true) .build() ) - .addAmountDiscountCreationParamsDiscount(0.0) + .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") @@ -347,37 +307,25 @@ internal class SubscriptionPriceIntervalsParamsTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice.builder() - .cadence( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Cadence - .ANNUAL - ) + SubscriptionPriceIntervalsParams.Add.Price.Unit.builder() + .cadence(SubscriptionPriceIntervalsParams.Add.Price.Unit.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .UnitConfig - .builder() + SubscriptionPriceIntervalsParams.Add.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -389,13 +337,12 @@ internal class SubscriptionPriceIntervalsParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -403,9 +350,7 @@ internal class SubscriptionPriceIntervalsParamsTest { .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .Metadata - .builder() + SubscriptionPriceIntervalsParams.Add.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -419,15 +364,8 @@ internal class SubscriptionPriceIntervalsParamsTest { .containsExactly( SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount + SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt index 8218d0f0..f6ed9305 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponseTest.kt @@ -22,15 +22,9 @@ internal class SubscriptionPriceIntervalsResponseTest { .id("id") .adjustment( SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -143,17 +137,10 @@ internal class SubscriptionPriceIntervalsResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionPriceIntervalsResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionPriceIntervalsResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionPriceIntervalsResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -201,12 +188,8 @@ internal class SubscriptionPriceIntervalsResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -292,25 +275,24 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -328,45 +310,43 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -412,25 +392,24 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -448,45 +427,43 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -704,16 +681,8 @@ internal class SubscriptionPriceIntervalsResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -754,32 +723,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -800,32 +767,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -833,23 +798,22 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -864,30 +828,23 @@ internal class SubscriptionPriceIntervalsResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1149,16 +1106,8 @@ internal class SubscriptionPriceIntervalsResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1199,32 +1148,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1245,32 +1192,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1278,23 +1223,22 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1309,30 +1253,23 @@ internal class SubscriptionPriceIntervalsResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1415,15 +1352,9 @@ internal class SubscriptionPriceIntervalsResponseTest { .id("id") .adjustment( SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1543,17 +1474,10 @@ internal class SubscriptionPriceIntervalsResponseTest { assertThat(subscriptionPriceIntervalsResponse.discountIntervals()) .containsExactly( SubscriptionPriceIntervalsResponse.DiscountInterval.ofAmount( - SubscriptionPriceIntervalsResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionPriceIntervalsResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionPriceIntervalsResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1610,12 +1534,8 @@ internal class SubscriptionPriceIntervalsResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1701,24 +1621,22 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1736,44 +1654,41 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1815,24 +1730,22 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1850,44 +1763,41 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2101,15 +2011,8 @@ internal class SubscriptionPriceIntervalsResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2150,30 +2053,28 @@ internal class SubscriptionPriceIntervalsResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2193,31 +2094,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2225,24 +2125,22 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2254,29 +2152,23 @@ internal class SubscriptionPriceIntervalsResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2527,15 +2419,8 @@ internal class SubscriptionPriceIntervalsResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2576,30 +2461,28 @@ internal class SubscriptionPriceIntervalsResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2619,31 +2502,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2651,24 +2533,22 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2680,29 +2560,23 @@ internal class SubscriptionPriceIntervalsResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2787,15 +2661,9 @@ internal class SubscriptionPriceIntervalsResponseTest { .id("id") .adjustment( SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionPriceIntervalsResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2908,17 +2776,10 @@ internal class SubscriptionPriceIntervalsResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionPriceIntervalsResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionPriceIntervalsResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionPriceIntervalsResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -2966,12 +2827,8 @@ internal class SubscriptionPriceIntervalsResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3057,25 +2914,24 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3093,45 +2949,43 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3177,25 +3031,24 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3213,45 +3066,43 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3469,16 +3320,8 @@ internal class SubscriptionPriceIntervalsResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3519,32 +3362,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3565,32 +3406,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3598,23 +3437,22 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3629,30 +3467,23 @@ internal class SubscriptionPriceIntervalsResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3914,16 +3745,8 @@ internal class SubscriptionPriceIntervalsResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3964,32 +3787,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4010,32 +3831,30 @@ internal class SubscriptionPriceIntervalsResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4043,23 +3862,22 @@ internal class SubscriptionPriceIntervalsResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4074,30 +3892,23 @@ internal class SubscriptionPriceIntervalsResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt index 26015afe..5f9971e9 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParamsTest.kt @@ -19,14 +19,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -69,26 +63,15 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -96,14 +79,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -116,14 +97,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -131,9 +110,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -185,14 +162,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -234,26 +205,15 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .builder() + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit.builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit.Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .UnitConfig .builder() .unitAmount("unit_amount") @@ -262,14 +222,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -282,14 +240,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -297,8 +253,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -338,14 +293,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -389,26 +338,15 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .builder() + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .UnitConfig .builder() .unitAmount("unit_amount") @@ -417,14 +355,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -437,14 +373,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -452,8 +386,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -506,15 +439,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -558,26 +484,16 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .builder() + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit.builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .UnitConfig .builder() .unitAmount("unit_amount") @@ -586,14 +502,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + .Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -606,14 +521,13 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + .Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -621,8 +535,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -647,14 +560,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -698,26 +605,15 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -725,14 +621,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -745,14 +639,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -760,9 +652,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -818,14 +708,8 @@ internal class SubscriptionSchedulePlanChangeParamsTest { SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -868,26 +752,15 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .builder() + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit.builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit.Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .UnitConfig .builder() .unitAmount("unit_amount") @@ -896,14 +769,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -916,14 +787,12 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -931,8 +800,7 @@ internal class SubscriptionSchedulePlanChangeParamsTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt index f148f1a6..0d167d70 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponseTest.kt @@ -22,16 +22,9 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .id("id") .adjustment( SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -144,17 +137,10 @@ internal class SubscriptionSchedulePlanChangeResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionSchedulePlanChangeResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionSchedulePlanChangeResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionSchedulePlanChangeResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -202,12 +188,8 @@ internal class SubscriptionSchedulePlanChangeResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -293,25 +275,24 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -329,45 +310,43 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -413,25 +392,24 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -449,45 +427,43 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -705,16 +681,8 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -755,32 +723,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -801,32 +767,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -834,23 +798,22 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -865,30 +828,23 @@ internal class SubscriptionSchedulePlanChangeResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1150,16 +1106,8 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1200,32 +1148,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1246,32 +1192,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1279,23 +1223,22 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1310,30 +1253,23 @@ internal class SubscriptionSchedulePlanChangeResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1416,15 +1352,9 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .id("id") .adjustment( SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1544,17 +1474,10 @@ internal class SubscriptionSchedulePlanChangeResponseTest { assertThat(subscriptionSchedulePlanChangeResponse.discountIntervals()) .containsExactly( SubscriptionSchedulePlanChangeResponse.DiscountInterval.ofAmount( - SubscriptionSchedulePlanChangeResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionSchedulePlanChangeResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionSchedulePlanChangeResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1611,12 +1534,8 @@ internal class SubscriptionSchedulePlanChangeResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1702,24 +1621,22 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1737,44 +1654,41 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1817,24 +1731,22 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1852,44 +1764,41 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2103,15 +2012,8 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2152,30 +2054,28 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2195,31 +2095,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2227,24 +2126,22 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2256,29 +2153,23 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2529,15 +2420,8 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2578,30 +2462,28 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2621,31 +2503,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2653,24 +2534,22 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2682,29 +2561,23 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2789,16 +2662,9 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .id("id") .adjustment( SubscriptionSchedulePlanChangeResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionSchedulePlanChangeResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2911,17 +2777,10 @@ internal class SubscriptionSchedulePlanChangeResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionSchedulePlanChangeResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionSchedulePlanChangeResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionSchedulePlanChangeResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -2969,12 +2828,8 @@ internal class SubscriptionSchedulePlanChangeResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3060,25 +2915,24 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3096,45 +2950,43 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3180,25 +3032,24 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3216,45 +3067,43 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3472,16 +3321,8 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3522,32 +3363,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3568,32 +3407,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3601,23 +3438,22 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3632,30 +3468,23 @@ internal class SubscriptionSchedulePlanChangeResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3917,16 +3746,8 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3967,32 +3788,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4013,32 +3832,30 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4046,23 +3863,22 @@ internal class SubscriptionSchedulePlanChangeResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4077,30 +3893,23 @@ internal class SubscriptionSchedulePlanChangeResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") 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 e286f522..20ab4d9f 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 @@ -21,16 +21,8 @@ internal class SubscriptionTest { Subscription.AdjustmentInterval.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + Subscription.AdjustmentInterval.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -143,13 +135,10 @@ internal class SubscriptionTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + Subscription.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval.DiscountType.AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -195,12 +184,8 @@ internal class SubscriptionTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -286,25 +271,24 @@ internal class SubscriptionTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -322,45 +306,43 @@ internal class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -404,25 +386,24 @@ internal class SubscriptionTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -440,45 +421,43 @@ internal class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -512,15 +491,8 @@ internal class SubscriptionTest { Subscription.AdjustmentInterval.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment.PlanPhaseUsageDiscountAdjustment - .builder() + Subscription.AdjustmentInterval.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -639,13 +611,10 @@ internal class SubscriptionTest { assertThat(subscription.discountIntervals()) .containsExactly( Subscription.DiscountInterval.ofAmount( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + Subscription.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval.DiscountType.AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -697,12 +666,8 @@ internal class SubscriptionTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -788,24 +753,22 @@ internal class SubscriptionTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -823,44 +786,41 @@ internal class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -901,24 +861,22 @@ internal class SubscriptionTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -936,44 +894,41 @@ internal class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1014,16 +969,8 @@ internal class SubscriptionTest { Subscription.AdjustmentInterval.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + Subscription.AdjustmentInterval.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1136,13 +1083,10 @@ internal class SubscriptionTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + Subscription.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval.DiscountType.AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1188,12 +1132,8 @@ internal class SubscriptionTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1279,25 +1219,24 @@ internal class SubscriptionTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1315,45 +1254,43 @@ internal class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1397,25 +1334,24 @@ internal class SubscriptionTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1433,45 +1369,43 @@ internal class SubscriptionTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt index 6dcd43e4..e4e557d7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponseTest.kt @@ -22,15 +22,9 @@ internal class SubscriptionTriggerPhaseResponseTest { .id("id") .adjustment( SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -143,16 +137,10 @@ internal class SubscriptionTriggerPhaseResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionTriggerPhaseResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -200,12 +188,8 @@ internal class SubscriptionTriggerPhaseResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -291,25 +275,24 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -327,45 +310,43 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -411,25 +392,24 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -447,45 +427,43 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -703,16 +681,8 @@ internal class SubscriptionTriggerPhaseResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -753,32 +723,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -799,32 +767,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -832,23 +798,22 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -863,30 +828,23 @@ internal class SubscriptionTriggerPhaseResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1148,16 +1106,8 @@ internal class SubscriptionTriggerPhaseResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1198,32 +1148,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1244,32 +1192,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1277,23 +1223,22 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1308,30 +1253,23 @@ internal class SubscriptionTriggerPhaseResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1413,16 +1351,9 @@ internal class SubscriptionTriggerPhaseResponseTest { SubscriptionTriggerPhaseResponse.AdjustmentInterval.builder() .id("id") .adjustment( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1542,16 +1473,10 @@ internal class SubscriptionTriggerPhaseResponseTest { assertThat(subscriptionTriggerPhaseResponse.discountIntervals()) .containsExactly( SubscriptionTriggerPhaseResponse.DiscountInterval.ofAmount( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionTriggerPhaseResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1608,12 +1533,8 @@ internal class SubscriptionTriggerPhaseResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1699,24 +1620,22 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1734,44 +1653,41 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1813,24 +1729,22 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1848,44 +1762,41 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2099,15 +2010,8 @@ internal class SubscriptionTriggerPhaseResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2148,30 +2052,28 @@ internal class SubscriptionTriggerPhaseResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2191,31 +2093,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2223,24 +2124,22 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2252,29 +2151,23 @@ internal class SubscriptionTriggerPhaseResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2525,15 +2418,8 @@ internal class SubscriptionTriggerPhaseResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2574,30 +2460,28 @@ internal class SubscriptionTriggerPhaseResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2617,31 +2501,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2649,24 +2532,22 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2678,29 +2559,23 @@ internal class SubscriptionTriggerPhaseResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2785,15 +2660,9 @@ internal class SubscriptionTriggerPhaseResponseTest { .id("id") .adjustment( SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionTriggerPhaseResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2906,16 +2775,10 @@ internal class SubscriptionTriggerPhaseResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionTriggerPhaseResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionTriggerPhaseResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -2963,12 +2826,8 @@ internal class SubscriptionTriggerPhaseResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3054,25 +2913,24 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3090,45 +2948,43 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3174,25 +3030,24 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3210,45 +3065,43 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3466,16 +3319,8 @@ internal class SubscriptionTriggerPhaseResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3516,32 +3361,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3562,32 +3405,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3595,23 +3436,22 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3626,30 +3466,23 @@ internal class SubscriptionTriggerPhaseResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3911,16 +3744,8 @@ internal class SubscriptionTriggerPhaseResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3961,32 +3786,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4007,32 +3830,30 @@ internal class SubscriptionTriggerPhaseResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4040,23 +3861,22 @@ internal class SubscriptionTriggerPhaseResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4071,30 +3891,23 @@ internal class SubscriptionTriggerPhaseResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt index 2b1a5fdf..d49882f7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponseTest.kt @@ -22,16 +22,9 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .id("id") .adjustment( SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -145,18 +138,10 @@ internal class SubscriptionUnscheduleCancellationResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .builder() + SubscriptionUnscheduleCancellationResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -204,12 +189,8 @@ internal class SubscriptionUnscheduleCancellationResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -295,25 +276,24 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -331,45 +311,43 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -415,25 +393,24 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -451,45 +428,43 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -707,16 +682,8 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -757,32 +724,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -803,32 +768,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -836,23 +799,22 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -867,30 +829,23 @@ internal class SubscriptionUnscheduleCancellationResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1152,16 +1107,8 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1202,32 +1149,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1248,32 +1193,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1281,23 +1224,22 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1312,30 +1254,23 @@ internal class SubscriptionUnscheduleCancellationResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1418,16 +1353,9 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .id("id") .adjustment( SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1547,18 +1475,10 @@ internal class SubscriptionUnscheduleCancellationResponseTest { assertThat(subscriptionUnscheduleCancellationResponse.discountIntervals()) .containsExactly( SubscriptionUnscheduleCancellationResponse.DiscountInterval.ofAmount( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .builder() + SubscriptionUnscheduleCancellationResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1615,12 +1535,8 @@ internal class SubscriptionUnscheduleCancellationResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1706,24 +1622,22 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1741,44 +1655,41 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1821,24 +1732,22 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1856,44 +1765,41 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2107,15 +2013,8 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2156,30 +2055,28 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2199,31 +2096,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2231,24 +2127,22 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2260,29 +2154,23 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2533,15 +2421,8 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2582,30 +2463,28 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2625,31 +2504,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2657,24 +2535,22 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2686,29 +2562,23 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2793,16 +2663,9 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .id("id") .adjustment( SubscriptionUnscheduleCancellationResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUnscheduleCancellationResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2916,18 +2779,10 @@ internal class SubscriptionUnscheduleCancellationResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .builder() + SubscriptionUnscheduleCancellationResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleCancellationResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -2975,12 +2830,8 @@ internal class SubscriptionUnscheduleCancellationResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3066,25 +2917,24 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3102,45 +2952,43 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3186,25 +3034,24 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3222,45 +3069,43 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3478,16 +3323,8 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3528,32 +3365,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3574,32 +3409,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3607,23 +3440,22 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3638,30 +3470,23 @@ internal class SubscriptionUnscheduleCancellationResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3923,16 +3748,8 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3973,32 +3790,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4019,32 +3834,30 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4052,23 +3865,22 @@ internal class SubscriptionUnscheduleCancellationResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4083,30 +3895,23 @@ internal class SubscriptionUnscheduleCancellationResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt index 3133426a..6554731d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest.kt @@ -24,17 +24,9 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .adjustment( SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -149,18 +141,11 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -210,12 +195,8 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -301,25 +282,24 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -337,45 +317,43 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -421,25 +399,24 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -457,45 +434,43 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -713,16 +688,8 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -763,32 +730,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -809,32 +774,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -842,23 +805,22 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -873,30 +835,23 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1158,16 +1113,8 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1208,32 +1155,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1254,32 +1199,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1287,23 +1230,22 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1318,30 +1260,23 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1426,17 +1361,9 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .adjustment( SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1568,18 +1495,11 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { assertThat(subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.discountIntervals()) .containsExactly( SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval.ofAmount( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1640,12 +1560,8 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1731,24 +1647,22 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1766,44 +1680,41 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1846,24 +1757,22 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1881,44 +1790,41 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2132,15 +2038,8 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2181,30 +2080,28 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2224,31 +2121,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2256,24 +2152,22 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2285,29 +2179,23 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2558,15 +2446,8 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2607,30 +2488,28 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2650,31 +2529,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2682,24 +2560,22 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2711,29 +2587,23 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2820,17 +2690,9 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .adjustment( SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2945,18 +2807,11 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval + SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -3006,12 +2861,8 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3097,25 +2948,24 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3133,45 +2983,43 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3217,25 +3065,24 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3253,45 +3100,43 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3509,16 +3354,8 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3559,32 +3396,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3605,32 +3440,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3638,23 +3471,22 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3669,30 +3501,23 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3954,16 +3779,8 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -4004,32 +3821,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4050,32 +3865,30 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4083,23 +3896,22 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4114,30 +3926,23 @@ internal class SubscriptionUnscheduleFixedFeeQuantityUpdatesResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt index e743458f..b20a6a6d 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponseTest.kt @@ -23,17 +23,9 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .adjustment( SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUnschedulePendingPlanChangesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -147,18 +139,11 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval + SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -208,12 +193,8 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -299,25 +280,24 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -335,45 +315,43 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -419,25 +397,24 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -455,45 +432,43 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -711,16 +686,8 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -761,32 +728,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -807,32 +772,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -840,23 +803,22 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -871,30 +833,23 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1156,16 +1111,8 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1206,32 +1153,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1252,32 +1197,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1285,23 +1228,22 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1316,30 +1258,23 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1424,16 +1359,9 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .adjustment( SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1556,18 +1484,11 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { assertThat(subscriptionUnschedulePendingPlanChangesResponse.discountIntervals()) .containsExactly( SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval.ofAmount( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval + SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1624,12 +1545,8 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1715,24 +1632,22 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1750,44 +1665,41 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1830,24 +1742,22 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1865,44 +1775,41 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2116,15 +2023,8 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2165,30 +2065,28 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2208,31 +2106,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2240,24 +2137,22 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2269,29 +2164,23 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2542,15 +2431,8 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2591,30 +2473,28 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2634,31 +2514,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2666,24 +2545,22 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2695,29 +2572,23 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2803,17 +2674,9 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .adjustment( SubscriptionUnschedulePendingPlanChangesResponse.AdjustmentInterval .Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUnschedulePendingPlanChangesResponse - .AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2927,18 +2790,11 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval + SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval.Amount .builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUnschedulePendingPlanChangesResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -2988,12 +2844,8 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3079,25 +2931,24 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3115,45 +2966,43 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3199,25 +3048,24 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3235,45 +3083,43 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3491,16 +3337,8 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3541,32 +3379,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3587,32 +3423,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3620,23 +3454,22 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3651,30 +3484,23 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3936,16 +3762,8 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3986,32 +3804,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4032,32 +3848,30 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4065,23 +3879,22 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4096,30 +3909,23 @@ internal class SubscriptionUnschedulePendingPlanChangesResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt index dc0a8f11..e4820717 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponseTest.kt @@ -22,16 +22,9 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .id("id") .adjustment( SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -145,18 +138,10 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .builder() + SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -204,12 +189,8 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -295,25 +276,24 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -331,45 +311,43 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -415,25 +393,24 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -451,45 +428,43 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -707,16 +682,8 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -757,32 +724,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -803,32 +768,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -836,23 +799,22 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -867,30 +829,23 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1152,16 +1107,8 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1202,32 +1149,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1248,32 +1193,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1281,23 +1224,22 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1312,30 +1254,23 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1418,16 +1353,9 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .id("id") .adjustment( SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1547,18 +1475,10 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { assertThat(subscriptionUpdateFixedFeeQuantityResponse.discountIntervals()) .containsExactly( SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval.ofAmount( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .builder() + SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1615,12 +1535,8 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1706,24 +1622,22 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1741,44 +1655,41 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1821,24 +1732,22 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1856,44 +1765,41 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2107,15 +2013,8 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2156,30 +2055,28 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2199,31 +2096,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2231,24 +2127,22 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2260,29 +2154,23 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2533,15 +2421,8 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2582,30 +2463,28 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2625,31 +2504,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2657,24 +2535,22 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2686,29 +2562,23 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2793,16 +2663,9 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .id("id") .adjustment( SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUpdateFixedFeeQuantityResponse.AdjustmentInterval - .Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2916,18 +2779,10 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .builder() + SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateFixedFeeQuantityResponse.DiscountInterval - .AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -2975,12 +2830,8 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3066,25 +2917,24 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3102,45 +2952,43 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3186,25 +3034,24 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3222,45 +3069,43 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3478,16 +3323,8 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3528,32 +3365,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3574,32 +3409,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3607,23 +3440,22 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3638,30 +3470,23 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3923,16 +3748,8 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3973,32 +3790,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4019,32 +3834,30 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4052,23 +3865,22 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4083,30 +3895,23 @@ internal class SubscriptionUpdateFixedFeeQuantityResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt index 1794498b..e43a83d7 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponseTest.kt @@ -22,15 +22,9 @@ internal class SubscriptionUpdateTrialResponseTest { .id("id") .adjustment( SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -143,16 +137,10 @@ internal class SubscriptionUpdateTrialResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionUpdateTrialResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -200,12 +188,8 @@ internal class SubscriptionUpdateTrialResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -291,25 +275,24 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -327,45 +310,43 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -410,25 +391,24 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -446,45 +426,43 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -702,16 +680,8 @@ internal class SubscriptionUpdateTrialResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -752,32 +722,30 @@ internal class SubscriptionUpdateTrialResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -798,32 +766,30 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -831,23 +797,22 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -862,30 +827,23 @@ internal class SubscriptionUpdateTrialResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1147,16 +1105,8 @@ internal class SubscriptionUpdateTrialResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -1197,32 +1147,30 @@ internal class SubscriptionUpdateTrialResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1243,32 +1191,30 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1276,23 +1222,22 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -1307,30 +1252,23 @@ internal class SubscriptionUpdateTrialResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -1412,16 +1350,9 @@ internal class SubscriptionUpdateTrialResponseTest { SubscriptionUpdateTrialResponse.AdjustmentInterval.builder() .id("id") .adjustment( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1541,16 +1472,10 @@ internal class SubscriptionUpdateTrialResponseTest { assertThat(subscriptionUpdateTrialResponse.discountIntervals()) .containsExactly( SubscriptionUpdateTrialResponse.DiscountInterval.ofAmount( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionUpdateTrialResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1605,12 +1530,8 @@ internal class SubscriptionUpdateTrialResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1696,24 +1617,22 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1731,44 +1650,41 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1810,24 +1726,22 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") - .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() - ) + .billableMetric(Price.Unit.BillableMetric.builder().id("id").build()) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit.DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1845,44 +1759,41 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit.DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() - .unitAmount("unit_amount") - .build() + Price.Unit.UnitConfig.builder().unitAmount("unit_amount").build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -2096,15 +2007,8 @@ internal class SubscriptionUpdateTrialResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2145,30 +2049,28 @@ internal class SubscriptionUpdateTrialResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2188,31 +2090,30 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2220,24 +2121,22 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2249,29 +2148,23 @@ internal class SubscriptionUpdateTrialResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2522,15 +2415,8 @@ internal class SubscriptionUpdateTrialResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment.MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -2571,30 +2457,28 @@ internal class SubscriptionUpdateTrialResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -2614,31 +2498,30 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -2646,24 +2529,22 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration - .builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -2675,29 +2556,23 @@ internal class SubscriptionUpdateTrialResponseTest { .quantity(1.0) .startDate(OffsetDateTime.parse("2022-02-01T08:00:00+00:00")) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -2782,15 +2657,9 @@ internal class SubscriptionUpdateTrialResponseTest { .id("id") .adjustment( SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + .UsageDiscount .builder() .id("id") - .adjustmentType( - SubscriptionUpdateTrialResponse.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -2903,16 +2772,10 @@ internal class SubscriptionUpdateTrialResponseTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .builder() + SubscriptionUpdateTrialResponse.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - SubscriptionUpdateTrialResponse.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -2960,12 +2823,8 @@ internal class SubscriptionUpdateTrialResponseTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -3051,25 +2910,24 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3087,45 +2945,43 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3170,25 +3026,24 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration.DurationUnit - .DAY + Price.Unit.BillingCycleConfiguration.DurationUnit.DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3206,45 +3061,43 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration.DurationUnit - .DAY + Price.Unit.InvoicingCycleConfiguration.DurationUnit.DAY ) .build() ) - .item(Price.UnitPrice.Item.builder().id("id").name("name").build()) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -3462,16 +3315,8 @@ internal class SubscriptionUpdateTrialResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3512,32 +3357,30 @@ internal class SubscriptionUpdateTrialResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -3558,32 +3401,30 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -3591,23 +3432,22 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -3622,30 +3462,23 @@ internal class SubscriptionUpdateTrialResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") @@ -3907,16 +3740,8 @@ internal class SubscriptionUpdateTrialResponseTest { .id("id") .adjustedSubtotal("5.00") .addAdjustment( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .builder() + Invoice.LineItem.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Invoice.LineItem.Adjustment - .MonetaryUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .amount("amount") .addAppliesToPriceId("string") .isInvoiceLevel(true) @@ -3957,32 +3782,30 @@ internal class SubscriptionUpdateTrialResponseTest { .name("Fixed Fee") .partiallyInvoicedAmount("4.00") .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() + Price.Unit.BillableMetric.builder() .id("id") .build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration - .builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt( OffsetDateTime.parse("2019-12-27T18:11:19.117Z") ) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -4003,32 +3826,30 @@ internal class SubscriptionUpdateTrialResponseTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration - .builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice - .InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() + Price.Unit.Item.builder() .id("id") .name("name") .build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -4036,23 +3857,22 @@ internal class SubscriptionUpdateTrialResponseTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration + Price.Unit.DimensionalPriceConfiguration .builder() .addDimensionValue("string") .dimensionalPriceGroupId( @@ -4067,30 +3887,23 @@ internal class SubscriptionUpdateTrialResponseTest { OffsetDateTime.parse("2022-02-01T08:00:00+00:00") ) .addSubLineItem( - Invoice.LineItem.SubLineItem.MatrixSubLineItem.builder() + Invoice.LineItem.SubLineItem.Matrix.builder() .amount("9.00") .grouping( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Grouping + Invoice.LineItem.SubLineItem.Matrix.Grouping .builder() .key("region") .value("west") .build() ) .matrixConfig( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .MatrixConfig + Invoice.LineItem.SubLineItem.Matrix.MatrixConfig .builder() .addDimensionValue("string") .build() ) .name("Tier One") .quantity(5.0) - .type( - Invoice.LineItem.SubLineItem.MatrixSubLineItem - .Type - .MATRIX - ) .build() ) .subtotal("9.00") 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 f638ba37..8939226f 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 @@ -23,16 +23,9 @@ internal class SubscriptionsTest { Subscription.AdjustmentInterval.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + Subscription.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -150,15 +143,10 @@ internal class SubscriptionsTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + Subscription.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -204,13 +192,8 @@ internal class SubscriptionsTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -298,28 +281,26 @@ internal class SubscriptionsTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -339,30 +320,27 @@ internal class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -370,23 +348,22 @@ internal class SubscriptionsTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -434,28 +411,26 @@ internal class SubscriptionsTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -475,30 +450,27 @@ internal class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -506,23 +478,22 @@ internal class SubscriptionsTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -565,16 +536,8 @@ internal class SubscriptionsTest { Subscription.AdjustmentInterval.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .builder() + Subscription.AdjustmentInterval.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -688,14 +651,10 @@ internal class SubscriptionsTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + Subscription.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval.DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -741,13 +700,8 @@ internal class SubscriptionsTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -835,26 +789,25 @@ internal class SubscriptionsTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -874,48 +827,44 @@ internal class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -959,26 +908,25 @@ internal class SubscriptionsTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder().id("id").build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration - .DurationUnit + Price.Unit.BillingCycleConfiguration.DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -998,48 +946,44 @@ internal class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration - .DurationUnit + Price.Unit.InvoicingCycleConfiguration.DurationUnit .DAY ) .build() ) - .item( - Price.UnitPrice.Item.builder().id("id").name("name").build() - ) + .item(Price.Unit.Item.builder().id("id").name("name").build()) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId("dimensional_price_group_id") .build() @@ -1083,16 +1027,9 @@ internal class SubscriptionsTest { Subscription.AdjustmentInterval.builder() .id("id") .adjustment( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment + Subscription.AdjustmentInterval.Adjustment.UsageDiscount .builder() .id("id") - .adjustmentType( - Subscription.AdjustmentInterval.Adjustment - .PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1210,15 +1147,10 @@ internal class SubscriptionsTest { ) .defaultInvoiceMemo("default_invoice_memo") .addDiscountInterval( - Subscription.DiscountInterval.AmountDiscountInterval.builder() + Subscription.DiscountInterval.Amount.builder() .amountDiscount("amount_discount") .addAppliesToPriceId("string") .addAppliesToPriceIntervalId("string") - .discountType( - Subscription.DiscountInterval.AmountDiscountInterval - .DiscountType - .AMOUNT - ) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .startDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() @@ -1264,13 +1196,8 @@ internal class SubscriptionsTest { Plan.builder() .id("id") .addAdjustment( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment.builder() + Plan.Adjustment.UsageDiscount.builder() .id("id") - .adjustmentType( - Plan.Adjustment.PlanPhaseUsageDiscountAdjustment - .AdjustmentType - .USAGE_DISCOUNT - ) .addAppliesToPriceId("string") .isInvoiceLevel(true) .planPhaseOrder(0L) @@ -1358,28 +1285,26 @@ internal class SubscriptionsTest { .build() ) .addPrice( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1399,30 +1324,27 @@ internal class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1430,23 +1352,22 @@ internal class SubscriptionsTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" @@ -1494,28 +1415,26 @@ internal class SubscriptionsTest { .build() ) .price( - Price.UnitPrice.builder() + Price.Unit.builder() .id("id") .billableMetric( - Price.UnitPrice.BillableMetric.builder() - .id("id") - .build() + Price.Unit.BillableMetric.builder().id("id").build() ) .billingCycleConfiguration( - Price.UnitPrice.BillingCycleConfiguration.builder() + Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.BillingCycleConfiguration + Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) .build() ) - .cadence(Price.UnitPrice.Cadence.ONE_TIME) + .cadence(Price.Unit.Cadence.ONE_TIME) .conversionRate(0.0) .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .creditAllocation( - Price.UnitPrice.CreditAllocation.builder() + Price.Unit.CreditAllocation.builder() .allowsRollover(true) .currency("currency") .build() @@ -1535,30 +1454,27 @@ internal class SubscriptionsTest { .externalPriceId("external_price_id") .fixedPriceQuantity(0.0) .invoicingCycleConfiguration( - Price.UnitPrice.InvoicingCycleConfiguration.builder() + Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - Price.UnitPrice.InvoicingCycleConfiguration + Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .item( - Price.UnitPrice.Item.builder() - .id("id") - .name("name") - .build() + Price.Unit.Item.builder().id("id").name("name").build() ) .maximum( - Price.UnitPrice.Maximum.builder() + Price.Unit.Maximum.builder() .addAppliesToPriceId("string") .maximumAmount("maximum_amount") .build() ) .maximumAmount("maximum_amount") .metadata( - Price.UnitPrice.Metadata.builder() + Price.Unit.Metadata.builder() .putAdditionalProperty( "foo", JsonValue.from("string"), @@ -1566,23 +1482,22 @@ internal class SubscriptionsTest { .build() ) .minimum( - Price.UnitPrice.Minimum.builder() + Price.Unit.Minimum.builder() .addAppliesToPriceId("string") .minimumAmount("minimum_amount") .build() ) .minimumAmount("minimum_amount") - .modelType(Price.UnitPrice.ModelType.UNIT) .name("name") .planPhaseOrder(0L) - .priceType(Price.UnitPrice.PriceType.USAGE_PRICE) + .priceType(Price.Unit.PriceType.USAGE_PRICE) .unitConfig( - Price.UnitPrice.UnitConfig.builder() + Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .dimensionalPriceConfiguration( - Price.UnitPrice.DimensionalPriceConfiguration.builder() + Price.Unit.DimensionalPriceConfiguration.builder() .addDimensionValue("string") .dimensionalPriceGroupId( "dimensional_price_group_id" 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 bdd64545..a190d0f3 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 @@ -28,8 +28,10 @@ import org.assertj.core.api.Assertions.entry import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.parallel.ResourceLock @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") internal class ErrorHandlingTest { companion object { @@ -129,14 +131,8 @@ internal class ErrorHandlingTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -230,14 +226,8 @@ internal class ErrorHandlingTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -331,14 +321,8 @@ internal class ErrorHandlingTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -432,14 +416,8 @@ internal class ErrorHandlingTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -533,14 +511,8 @@ internal class ErrorHandlingTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -634,14 +606,8 @@ internal class ErrorHandlingTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -735,14 +701,8 @@ internal class ErrorHandlingTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -836,14 +796,8 @@ internal class ErrorHandlingTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -935,14 +889,8 @@ internal class ErrorHandlingTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) 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 120c2a73..d7e4bf39 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 @@ -18,8 +18,10 @@ import com.withorb.api.core.JsonValue import com.withorb.api.models.CustomerCreateParams import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") internal class ServiceParamsTest { private lateinit var client: OrbClient @@ -96,13 +98,8 @@ internal class ServiceParamsTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt index cd147e8a..85fd4331 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/AlertServiceAsyncTest.kt @@ -9,7 +9,6 @@ import com.withorb.api.models.AlertCreateForExternalCustomerParams import com.withorb.api.models.AlertCreateForSubscriptionParams import com.withorb.api.models.AlertDisableParams import com.withorb.api.models.AlertEnableParams -import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -27,8 +26,7 @@ internal class AlertServiceAsyncTest { .build() val alertServiceAsync = client.alerts() - val alertFuture = - alertServiceAsync.retrieve(AlertRetrieveParams.builder().alertId("alert_id").build()) + val alertFuture = alertServiceAsync.retrieve("alert_id") val alert = alertFuture.get() alert.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CouponServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CouponServiceAsyncTest.kt index 28c7dbf4..17586112 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CouponServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CouponServiceAsyncTest.kt @@ -4,9 +4,7 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync -import com.withorb.api.models.CouponArchiveParams import com.withorb.api.models.CouponCreateParams -import com.withorb.api.models.CouponFetchParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,7 +23,7 @@ internal class CouponServiceAsyncTest { val couponFuture = couponServiceAsync.create( CouponCreateParams.builder() - .newCouponPercentageDiscount(0.0) + .percentageDiscount(0.0) .redemptionCode("HALFOFF") .durationInMonths(12L) .maxRedemptions(1L) @@ -60,8 +58,7 @@ internal class CouponServiceAsyncTest { .build() val couponServiceAsync = client.coupons() - val couponFuture = - couponServiceAsync.archive(CouponArchiveParams.builder().couponId("coupon_id").build()) + val couponFuture = couponServiceAsync.archive("coupon_id") val coupon = couponFuture.get() coupon.validate() @@ -76,8 +73,7 @@ internal class CouponServiceAsyncTest { .build() val couponServiceAsync = client.coupons() - val couponFuture = - couponServiceAsync.fetch(CouponFetchParams.builder().couponId("coupon_id").build()) + val couponFuture = couponServiceAsync.fetch("coupon_id") val coupon = couponFuture.get() coupon.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncTest.kt index 8b097942..01119641 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/CreditNoteServiceAsyncTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.models.CreditNoteCreateParams -import com.withorb.api.models.CreditNoteFetchParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -63,10 +62,7 @@ internal class CreditNoteServiceAsyncTest { .build() val creditNoteServiceAsync = client.creditNotes() - val creditNoteFuture = - creditNoteServiceAsync.fetch( - CreditNoteFetchParams.builder().creditNoteId("credit_note_id").build() - ) + val creditNoteFuture = creditNoteServiceAsync.fetch("credit_note_id") val creditNote = creditNoteFuture.get() creditNote.validate() 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 e7518ed4..d37f76e4 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 @@ -6,11 +6,6 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.CustomerCreateParams -import com.withorb.api.models.CustomerDeleteParams -import com.withorb.api.models.CustomerFetchByExternalIdParams -import com.withorb.api.models.CustomerFetchParams -import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams -import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayParams import com.withorb.api.models.CustomerUpdateByExternalIdParams import com.withorb.api.models.CustomerUpdateParams import org.junit.jupiter.api.Test @@ -87,13 +82,8 @@ internal class CustomerServiceAsyncTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -181,13 +171,8 @@ internal class CustomerServiceAsyncTest { .build() ) .taxConfiguration( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerUpdateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -229,10 +214,7 @@ internal class CustomerServiceAsyncTest { .build() val customerServiceAsync = client.customers() - val future = - customerServiceAsync.delete( - CustomerDeleteParams.builder().customerId("customer_id").build() - ) + val future = customerServiceAsync.delete("customer_id") val response = future.get() } @@ -246,10 +228,7 @@ internal class CustomerServiceAsyncTest { .build() val customerServiceAsync = client.customers() - val customerFuture = - customerServiceAsync.fetch( - CustomerFetchParams.builder().customerId("customer_id").build() - ) + val customerFuture = customerServiceAsync.fetch("customer_id") val customer = customerFuture.get() customer.validate() @@ -264,12 +243,7 @@ internal class CustomerServiceAsyncTest { .build() val customerServiceAsync = client.customers() - val customerFuture = - customerServiceAsync.fetchByExternalId( - CustomerFetchByExternalIdParams.builder() - .externalCustomerId("external_customer_id") - .build() - ) + val customerFuture = customerServiceAsync.fetchByExternalId("external_customer_id") val customer = customerFuture.get() customer.validate() @@ -284,12 +258,7 @@ internal class CustomerServiceAsyncTest { .build() val customerServiceAsync = client.customers() - val future = - customerServiceAsync.syncPaymentMethodsFromGateway( - CustomerSyncPaymentMethodsFromGatewayParams.builder() - .customerId("customer_id") - .build() - ) + val future = customerServiceAsync.syncPaymentMethodsFromGateway("customer_id") val response = future.get() } @@ -305,9 +274,7 @@ internal class CustomerServiceAsyncTest { val future = customerServiceAsync.syncPaymentMethodsFromGatewayByExternalCustomerId( - CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.builder() - .externalCustomerId("external_customer_id") - .build() + "external_customer_id" ) val response = future.get() @@ -385,15 +352,8 @@ internal class CustomerServiceAsyncTest { .build() ) .taxConfiguration( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerUpdateByExternalIdParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncTest.kt index 17734966..2eb8b99a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/DimensionalPriceGroupServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.DimensionalPriceGroupCreateParams -import com.withorb.api.models.DimensionalPriceGroupRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -52,11 +51,7 @@ internal class DimensionalPriceGroupServiceAsyncTest { val dimensionalPriceGroupServiceAsync = client.dimensionalPriceGroups() val dimensionalPriceGroupFuture = - dimensionalPriceGroupServiceAsync.retrieve( - DimensionalPriceGroupRetrieveParams.builder() - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) + dimensionalPriceGroupServiceAsync.retrieve("dimensional_price_group_id") val dimensionalPriceGroup = dimensionalPriceGroupFuture.get() dimensionalPriceGroup.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/EventServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/EventServiceAsyncTest.kt index 034c78e6..9f2113ef 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/EventServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/EventServiceAsyncTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue -import com.withorb.api.models.EventDeprecateParams import com.withorb.api.models.EventIngestParams import com.withorb.api.models.EventSearchParams import com.withorb.api.models.EventUpdateParams @@ -50,8 +49,7 @@ internal class EventServiceAsyncTest { .build() val eventServiceAsync = client.events() - val responseFuture = - eventServiceAsync.deprecate(EventDeprecateParams.builder().eventId("event_id").build()) + val responseFuture = eventServiceAsync.deprecate("event_id") val response = responseFuture.get() response.validate() 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 adac4373..ddf20370 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 @@ -6,13 +6,10 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.InvoiceCreateParams -import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceMarkPaidParams -import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams -import com.withorb.api.models.InvoiceVoidInvoiceParams import com.withorb.api.models.PercentageDiscount import java.time.LocalDate import java.time.OffsetDateTime @@ -126,8 +123,7 @@ internal class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = - invoiceServiceAsync.fetch(InvoiceFetchParams.builder().invoiceId("invoice_id").build()) + val invoiceFuture = invoiceServiceAsync.fetch("invoice_id") val invoice = invoiceFuture.get() invoice.validate() @@ -201,8 +197,7 @@ internal class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = - invoiceServiceAsync.pay(InvoicePayParams.builder().invoiceId("invoice_id").build()) + val invoiceFuture = invoiceServiceAsync.pay("invoice_id") val invoice = invoiceFuture.get() invoice.validate() @@ -217,10 +212,7 @@ internal class InvoiceServiceAsyncTest { .build() val invoiceServiceAsync = client.invoices() - val invoiceFuture = - invoiceServiceAsync.voidInvoice( - InvoiceVoidInvoiceParams.builder().invoiceId("invoice_id").build() - ) + val invoiceFuture = invoiceServiceAsync.voidInvoice("invoice_id") val invoice = invoiceFuture.get() invoice.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/ItemServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/ItemServiceAsyncTest.kt index be1bd155..113d1dee 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/ItemServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/ItemServiceAsyncTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.models.ItemCreateParams -import com.withorb.api.models.ItemFetchParams import com.withorb.api.models.ItemUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -82,7 +81,7 @@ internal class ItemServiceAsyncTest { .build() val itemServiceAsync = client.items() - val itemFuture = itemServiceAsync.fetch(ItemFetchParams.builder().itemId("item_id").build()) + val itemFuture = itemServiceAsync.fetch("item_id") val item = itemFuture.get() item.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/MetricServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/MetricServiceAsyncTest.kt index 7aa9182b..baa06b68 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/MetricServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/MetricServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.MetricCreateParams -import com.withorb.api.models.MetricFetchParams import com.withorb.api.models.MetricUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -91,8 +90,7 @@ internal class MetricServiceAsyncTest { .build() val metricServiceAsync = client.metrics() - val billableMetricFuture = - metricServiceAsync.fetch(MetricFetchParams.builder().metricId("metric_id").build()) + val billableMetricFuture = metricServiceAsync.fetch("metric_id") val billableMetric = billableMetricFuture.get() billableMetric.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt index 5236adb8..b187ea6e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PlanServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.PlanCreateParams -import com.withorb.api.models.PlanFetchParams import com.withorb.api.models.PlanUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -29,25 +28,22 @@ internal class PlanServiceAsyncTest { .currency("currency") .name("name") .addPrice( - PlanCreateParams.Price.NewPlanUnitPrice.builder() - .cadence(PlanCreateParams.Price.NewPlanUnitPrice.Cadence.ANNUAL) + PlanCreateParams.Price.Unit.builder() + .cadence(PlanCreateParams.Price.Unit.Cadence.ANNUAL) .itemId("item_id") - .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() + PlanCreateParams.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .builder() + PlanCreateParams.Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .BillingCycleConfiguration + PlanCreateParams.Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) @@ -59,19 +55,17 @@ internal class PlanServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .InvoicingCycleConfiguration + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .metadata( - PlanCreateParams.Price.NewPlanUnitPrice.Metadata.builder() + PlanCreateParams.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -143,7 +137,7 @@ internal class PlanServiceAsyncTest { .build() val planServiceAsync = client.plans() - val planFuture = planServiceAsync.fetch(PlanFetchParams.builder().planId("plan_id").build()) + val planFuture = planServiceAsync.fetch("plan_id") val plan = planFuture.get() plan.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt index db3179f8..8fb3f09c 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/PriceServiceAsyncTest.kt @@ -7,7 +7,6 @@ import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateParams -import com.withorb.api.models.PriceFetchParams import com.withorb.api.models.PriceUpdateParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test @@ -29,27 +28,23 @@ internal class PriceServiceAsyncTest { priceServiceAsync.create( PriceCreateParams.builder() .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + PriceCreateParams.Body.Unit.builder() + .cadence(PriceCreateParams.Body.Unit.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() + PriceCreateParams.Body.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration + PriceCreateParams.Body.Unit.BillingCycleConfiguration .DurationUnit .DAY ) @@ -60,20 +55,17 @@ internal class PriceServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + PriceCreateParams.Body.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -161,8 +153,7 @@ internal class PriceServiceAsyncTest { .build() val priceServiceAsync = client.prices() - val priceFuture = - priceServiceAsync.fetch(PriceFetchParams.builder().priceId("price_id").build()) + val priceFuture = priceServiceAsync.fetch("price_id") val price = priceFuture.get() price.validate() 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 00fb85f9..3c74803f 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 @@ -5,8 +5,6 @@ package com.withorb.api.services.async import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.models.SubscriptionChangeApplyParams -import com.withorb.api.models.SubscriptionChangeCancelParams -import com.withorb.api.models.SubscriptionChangeRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,11 +21,7 @@ internal class SubscriptionChangeServiceAsyncTest { val subscriptionChangeServiceAsync = client.subscriptionChanges() val subscriptionChangeFuture = - subscriptionChangeServiceAsync.retrieve( - SubscriptionChangeRetrieveParams.builder() - .subscriptionChangeId("subscription_change_id") - .build() - ) + subscriptionChangeServiceAsync.retrieve("subscription_change_id") val subscriptionChange = subscriptionChangeFuture.get() subscriptionChange.validate() @@ -64,12 +58,7 @@ internal class SubscriptionChangeServiceAsyncTest { .build() val subscriptionChangeServiceAsync = client.subscriptionChanges() - val responseFuture = - subscriptionChangeServiceAsync.cancel( - SubscriptionChangeCancelParams.builder() - .subscriptionChangeId("subscription_change_id") - .build() - ) + val responseFuture = subscriptionChangeServiceAsync.cancel("subscription_change_id") val response = responseFuture.get() response.validate() 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 10923b97..2241860c 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 @@ -8,15 +8,11 @@ import com.withorb.api.core.JsonValue import com.withorb.api.models.SubscriptionCancelParams import com.withorb.api.models.SubscriptionCreateParams import com.withorb.api.models.SubscriptionFetchCostsParams -import com.withorb.api.models.SubscriptionFetchParams -import com.withorb.api.models.SubscriptionFetchScheduleParams import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionPriceIntervalsParams import com.withorb.api.models.SubscriptionSchedulePlanChangeParams import com.withorb.api.models.SubscriptionTriggerPhaseParams -import com.withorb.api.models.SubscriptionUnscheduleCancellationParams import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesParams -import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesParams import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams @@ -44,15 +40,8 @@ internal class SubscriptionServiceAsyncTest { .addAddAdjustment( SubscriptionCreateParams.AddAdjustment.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount + SubscriptionCreateParams.AddAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -94,26 +83,14 @@ internal class SubscriptionServiceAsyncTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionCreateParams.AddPrice.Price.Unit.builder() .cadence( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence - .ANNUAL + SubscriptionCreateParams.AddPrice.Price.Unit.Cadence.ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig + SubscriptionCreateParams.AddPrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -121,14 +98,12 @@ internal class SubscriptionServiceAsyncTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -141,14 +116,12 @@ internal class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -156,9 +129,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + SubscriptionCreateParams.AddPrice.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -217,14 +188,8 @@ internal class SubscriptionServiceAsyncTest { SubscriptionCreateParams.ReplaceAdjustment.builder() .adjustment( SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -265,26 +230,15 @@ internal class SubscriptionServiceAsyncTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionCreateParams.ReplacePrice.Price.Unit.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + SubscriptionCreateParams.ReplacePrice.Price.Unit.Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig + SubscriptionCreateParams.ReplacePrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -292,14 +246,12 @@ internal class SubscriptionServiceAsyncTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -312,14 +264,12 @@ internal class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -327,9 +277,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + SubscriptionCreateParams.ReplacePrice.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -426,10 +374,7 @@ internal class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val subscriptionFuture = - subscriptionServiceAsync.fetch( - SubscriptionFetchParams.builder().subscriptionId("subscription_id").build() - ) + val subscriptionFuture = subscriptionServiceAsync.fetch("subscription_id") val subscription = subscriptionFuture.get() subscription.validate() @@ -468,10 +413,7 @@ internal class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val pageFuture = - subscriptionServiceAsync.fetchSchedule( - SubscriptionFetchScheduleParams.builder().subscriptionId("subscription_id").build() - ) + val pageFuture = subscriptionServiceAsync.fetchSchedule("subscription_id") val page = pageFuture.get() page.response().validate() @@ -536,7 +478,7 @@ internal class SubscriptionServiceAsyncTest { .expiresAtEndOfCadence(true) .build() ) - .addAmountDiscountCreationParamsDiscount(0.0) + .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") @@ -550,27 +492,16 @@ internal class SubscriptionServiceAsyncTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .builder() + SubscriptionPriceIntervalsParams.Add.Price.Unit.builder() .cadence( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .Cadence + SubscriptionPriceIntervalsParams.Add.Price.Unit.Cadence .ANNUAL ) .currency("currency") .itemId("item_id") - .modelType( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .UnitConfig + SubscriptionPriceIntervalsParams.Add.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -578,14 +509,12 @@ internal class SubscriptionServiceAsyncTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -597,14 +526,12 @@ internal class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -612,9 +539,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .Metadata + SubscriptionPriceIntervalsParams.Add.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -629,14 +554,8 @@ internal class SubscriptionServiceAsyncTest { SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -697,15 +616,8 @@ internal class SubscriptionServiceAsyncTest { SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -751,26 +663,16 @@ internal class SubscriptionServiceAsyncTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .builder() + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .UnitConfig .builder() .unitAmount("unit_amount") @@ -779,14 +681,13 @@ internal class SubscriptionServiceAsyncTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + .Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -799,14 +700,13 @@ internal class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + .Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -814,8 +714,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -869,15 +768,8 @@ internal class SubscriptionServiceAsyncTest { SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -921,26 +813,17 @@ internal class SubscriptionServiceAsyncTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .UnitConfig .builder() .unitAmount("unit_amount") @@ -949,15 +832,14 @@ internal class SubscriptionServiceAsyncTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.ReplacePrice .Price - .NewSubscriptionUnitPrice + .Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -970,15 +852,14 @@ internal class SubscriptionServiceAsyncTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.ReplacePrice .Price - .NewSubscriptionUnitPrice + .Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -986,8 +867,7 @@ internal class SubscriptionServiceAsyncTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1039,12 +919,7 @@ internal class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.subscriptions() - val responseFuture = - subscriptionServiceAsync.unscheduleCancellation( - SubscriptionUnscheduleCancellationParams.builder() - .subscriptionId("subscription_id") - .build() - ) + val responseFuture = subscriptionServiceAsync.unscheduleCancellation("subscription_id") val response = responseFuture.get() response.validate() @@ -1081,11 +956,7 @@ internal class SubscriptionServiceAsyncTest { val subscriptionServiceAsync = client.subscriptions() val responseFuture = - subscriptionServiceAsync.unschedulePendingPlanChanges( - SubscriptionUnschedulePendingPlanChangesParams.builder() - .subscriptionId("subscription_id") - .build() - ) + subscriptionServiceAsync.unschedulePendingPlanChanges("subscription_id") val response = responseFuture.get() response.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncTest.kt index a11e29a1..30a1fa04 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/coupons/SubscriptionServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.services.async.coupons import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync -import com.withorb.api.models.CouponSubscriptionListParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,10 +19,7 @@ internal class SubscriptionServiceAsyncTest { .build() val subscriptionServiceAsync = client.coupons().subscriptions() - val pageFuture = - subscriptionServiceAsync.list( - CouponSubscriptionListParams.builder().couponId("coupon_id").build() - ) + val pageFuture = subscriptionServiceAsync.list("coupon_id") val page = pageFuture.get() page.response().validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncTest.kt index 47afac58..d23fd4d9 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/BalanceTransactionServiceAsyncTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.async.customers import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.models.CustomerBalanceTransactionCreateParams -import com.withorb.api.models.CustomerBalanceTransactionListParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -44,10 +43,7 @@ internal class BalanceTransactionServiceAsyncTest { .build() val balanceTransactionServiceAsync = client.customers().balanceTransactions() - val pageFuture = - balanceTransactionServiceAsync.list( - CustomerBalanceTransactionListParams.builder().customerId("customer_id").build() - ) + val pageFuture = balanceTransactionServiceAsync.list("customer_id") val page = pageFuture.get() page.response().validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncTest.kt index 2a9e925c..fd36b268 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/CreditServiceAsyncTest.kt @@ -4,8 +4,6 @@ package com.withorb.api.services.async.customers import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync -import com.withorb.api.models.CustomerCreditListByExternalIdParams -import com.withorb.api.models.CustomerCreditListParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -21,10 +19,7 @@ internal class CreditServiceAsyncTest { .build() val creditServiceAsync = client.customers().credits() - val pageFuture = - creditServiceAsync.list( - CustomerCreditListParams.builder().customerId("customer_id").build() - ) + val pageFuture = creditServiceAsync.list("customer_id") val page = pageFuture.get() page.response().validate() @@ -39,12 +34,7 @@ internal class CreditServiceAsyncTest { .build() val creditServiceAsync = client.customers().credits() - val pageFuture = - creditServiceAsync.listByExternalId( - CustomerCreditListByExternalIdParams.builder() - .externalCustomerId("external_customer_id") - .build() - ) + val pageFuture = creditServiceAsync.listByExternalId("external_customer_id") val page = pageFuture.get() page.response().validate() 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 78303918..d46450b7 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 @@ -7,8 +7,6 @@ import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerCreateEntryParams -import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams -import com.withorb.api.models.CustomerCreditLedgerListParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,10 +23,7 @@ internal class LedgerServiceAsyncTest { .build() val ledgerServiceAsync = client.customers().credits().ledger() - val pageFuture = - ledgerServiceAsync.list( - CustomerCreditLedgerListParams.builder().customerId("customer_id").build() - ) + val pageFuture = ledgerServiceAsync.list("customer_id") val page = pageFuture.get() page.response().validate() @@ -48,24 +43,14 @@ internal class LedgerServiceAsyncTest { CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") .body( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + CustomerCreditLedgerCreateEntryParams.Body.Increment.builder() .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) .currency("currency") .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .InvoiceSettings + CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() .autoCollection(true) .netTerms(0L) @@ -74,9 +59,7 @@ internal class LedgerServiceAsyncTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .Metadata + CustomerCreditLedgerCreateEntryParams.Body.Increment.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -105,23 +88,14 @@ internal class LedgerServiceAsyncTest { CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") .body( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.builder() .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) .currency("currency") .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .InvoiceSettings .builder() .autoCollection(true) @@ -131,8 +105,7 @@ internal class LedgerServiceAsyncTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -157,12 +130,7 @@ internal class LedgerServiceAsyncTest { .build() val ledgerServiceAsync = client.customers().credits().ledger() - val pageFuture = - ledgerServiceAsync.listByExternalId( - CustomerCreditLedgerListByExternalIdParams.builder() - .externalCustomerId("external_customer_id") - .build() - ) + val pageFuture = ledgerServiceAsync.listByExternalId("external_customer_id") val page = pageFuture.get() page.response().validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncTest.kt index de7dbfa5..55f1cf4a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/customers/credits/TopUpServiceAsyncTest.kt @@ -8,8 +8,6 @@ import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpCreateParams import com.withorb.api.models.CustomerCreditTopUpDeleteByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpDeleteParams -import com.withorb.api.models.CustomerCreditTopUpListByExternalIdParams -import com.withorb.api.models.CustomerCreditTopUpListParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -61,10 +59,7 @@ internal class TopUpServiceAsyncTest { .build() val topUpServiceAsync = client.customers().credits().topUps() - val pageFuture = - topUpServiceAsync.list( - CustomerCreditTopUpListParams.builder().customerId("customer_id").build() - ) + val pageFuture = topUpServiceAsync.list("customer_id") val page = pageFuture.get() page.response().validate() @@ -156,12 +151,7 @@ internal class TopUpServiceAsyncTest { .build() val topUpServiceAsync = client.customers().credits().topUps() - val pageFuture = - topUpServiceAsync.listByExternalId( - CustomerCreditTopUpListByExternalIdParams.builder() - .externalCustomerId("external_customer_id") - .build() - ) + val pageFuture = topUpServiceAsync.listByExternalId("external_customer_id") val page = pageFuture.get() page.response().validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncTest.kt index 15c364da..7a286bbe 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceAsyncTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.services.async.dimensionalPriceGroups import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync -import com.withorb.api.models.DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -23,9 +22,7 @@ internal class ExternalDimensionalPriceGroupIdServiceAsyncTest { val dimensionalPriceGroupFuture = externalDimensionalPriceGroupIdServiceAsync.retrieve( - DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.builder() - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() + "external_dimensional_price_group_id" ) val dimensionalPriceGroup = dimensionalPriceGroupFuture.get() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncTest.kt index 3fc16ab4..efed68fd 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/events/BackfillServiceAsyncTest.kt @@ -4,10 +4,7 @@ package com.withorb.api.services.async.events import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync -import com.withorb.api.models.EventBackfillCloseParams import com.withorb.api.models.EventBackfillCreateParams -import com.withorb.api.models.EventBackfillFetchParams -import com.withorb.api.models.EventBackfillRevertParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -65,10 +62,7 @@ internal class BackfillServiceAsyncTest { .build() val backfillServiceAsync = client.events().backfills() - val responseFuture = - backfillServiceAsync.close( - EventBackfillCloseParams.builder().backfillId("backfill_id").build() - ) + val responseFuture = backfillServiceAsync.close("backfill_id") val response = responseFuture.get() response.validate() @@ -83,10 +77,7 @@ internal class BackfillServiceAsyncTest { .build() val backfillServiceAsync = client.events().backfills() - val responseFuture = - backfillServiceAsync.fetch( - EventBackfillFetchParams.builder().backfillId("backfill_id").build() - ) + val responseFuture = backfillServiceAsync.fetch("backfill_id") val response = responseFuture.get() response.validate() @@ -101,10 +92,7 @@ internal class BackfillServiceAsyncTest { .build() val backfillServiceAsync = client.events().backfills() - val responseFuture = - backfillServiceAsync.revert( - EventBackfillRevertParams.builder().backfillId("backfill_id").build() - ) + val responseFuture = backfillServiceAsync.revert("backfill_id") val response = responseFuture.get() response.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncTest.kt index 3990a175..c600a995 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/plans/ExternalPlanIdServiceAsyncTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.async.plans import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue -import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -48,10 +47,7 @@ internal class ExternalPlanIdServiceAsyncTest { .build() val externalPlanIdServiceAsync = client.plans().externalPlanId() - val planFuture = - externalPlanIdServiceAsync.fetch( - PlanExternalPlanIdFetchParams.builder().externalPlanId("external_plan_id").build() - ) + val planFuture = externalPlanIdServiceAsync.fetch("external_plan_id") val plan = planFuture.get() plan.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncTest.kt index a73cc691..c01a21b5 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/async/prices/ExternalPriceIdServiceAsyncTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.async.prices import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClientAsync import com.withorb.api.core.JsonValue -import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -47,12 +46,7 @@ internal class ExternalPriceIdServiceAsyncTest { .build() val externalPriceIdServiceAsync = client.prices().externalPriceId() - val priceFuture = - externalPriceIdServiceAsync.fetch( - PriceExternalPriceIdFetchParams.builder() - .externalPriceId("external_price_id") - .build() - ) + val priceFuture = externalPriceIdServiceAsync.fetch("external_price_id") val price = priceFuture.get() price.validate() diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt index 479a9eae..015b5f2b 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/AlertServiceTest.kt @@ -9,7 +9,6 @@ import com.withorb.api.models.AlertCreateForExternalCustomerParams import com.withorb.api.models.AlertCreateForSubscriptionParams import com.withorb.api.models.AlertDisableParams import com.withorb.api.models.AlertEnableParams -import com.withorb.api.models.AlertRetrieveParams import com.withorb.api.models.AlertUpdateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -27,7 +26,7 @@ internal class AlertServiceTest { .build() val alertService = client.alerts() - val alert = alertService.retrieve(AlertRetrieveParams.builder().alertId("alert_id").build()) + val alert = alertService.retrieve("alert_id") alert.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CouponServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CouponServiceTest.kt index cd0ceeff..8f68b754 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CouponServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CouponServiceTest.kt @@ -4,9 +4,7 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient -import com.withorb.api.models.CouponArchiveParams import com.withorb.api.models.CouponCreateParams -import com.withorb.api.models.CouponFetchParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,7 +23,7 @@ internal class CouponServiceTest { val coupon = couponService.create( CouponCreateParams.builder() - .newCouponPercentageDiscount(0.0) + .percentageDiscount(0.0) .redemptionCode("HALFOFF") .durationInMonths(12L) .maxRedemptions(1L) @@ -58,8 +56,7 @@ internal class CouponServiceTest { .build() val couponService = client.coupons() - val coupon = - couponService.archive(CouponArchiveParams.builder().couponId("coupon_id").build()) + val coupon = couponService.archive("coupon_id") coupon.validate() } @@ -73,7 +70,7 @@ internal class CouponServiceTest { .build() val couponService = client.coupons() - val coupon = couponService.fetch(CouponFetchParams.builder().couponId("coupon_id").build()) + val coupon = couponService.fetch("coupon_id") coupon.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditNoteServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditNoteServiceTest.kt index 1e1f88b3..57a5ee0a 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditNoteServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/CreditNoteServiceTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.models.CreditNoteCreateParams -import com.withorb.api.models.CreditNoteFetchParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -61,10 +60,7 @@ internal class CreditNoteServiceTest { .build() val creditNoteService = client.creditNotes() - val creditNote = - creditNoteService.fetch( - CreditNoteFetchParams.builder().creditNoteId("credit_note_id").build() - ) + val creditNote = creditNoteService.fetch("credit_note_id") creditNote.validate() } 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 c5744a00..278309a6 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 @@ -6,11 +6,6 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.CustomerCreateParams -import com.withorb.api.models.CustomerDeleteParams -import com.withorb.api.models.CustomerFetchByExternalIdParams -import com.withorb.api.models.CustomerFetchParams -import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams -import com.withorb.api.models.CustomerSyncPaymentMethodsFromGatewayParams import com.withorb.api.models.CustomerUpdateByExternalIdParams import com.withorb.api.models.CustomerUpdateParams import org.junit.jupiter.api.Test @@ -87,13 +82,8 @@ internal class CustomerServiceTest { .build() ) .taxConfiguration( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerCreateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerCreateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -180,13 +170,8 @@ internal class CustomerServiceTest { .build() ) .taxConfiguration( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration.builder() + CustomerUpdateParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateParams.TaxConfiguration.NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) @@ -226,7 +211,7 @@ internal class CustomerServiceTest { .build() val customerService = client.customers() - customerService.delete(CustomerDeleteParams.builder().customerId("customer_id").build()) + customerService.delete("customer_id") } @Test @@ -238,8 +223,7 @@ internal class CustomerServiceTest { .build() val customerService = client.customers() - val customer = - customerService.fetch(CustomerFetchParams.builder().customerId("customer_id").build()) + val customer = customerService.fetch("customer_id") customer.validate() } @@ -253,12 +237,7 @@ internal class CustomerServiceTest { .build() val customerService = client.customers() - val customer = - customerService.fetchByExternalId( - CustomerFetchByExternalIdParams.builder() - .externalCustomerId("external_customer_id") - .build() - ) + val customer = customerService.fetchByExternalId("external_customer_id") customer.validate() } @@ -272,9 +251,7 @@ internal class CustomerServiceTest { .build() val customerService = client.customers() - customerService.syncPaymentMethodsFromGateway( - CustomerSyncPaymentMethodsFromGatewayParams.builder().customerId("customer_id").build() - ) + customerService.syncPaymentMethodsFromGateway("customer_id") } @Test @@ -286,11 +263,7 @@ internal class CustomerServiceTest { .build() val customerService = client.customers() - customerService.syncPaymentMethodsFromGatewayByExternalCustomerId( - CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIdParams.builder() - .externalCustomerId("external_customer_id") - .build() - ) + customerService.syncPaymentMethodsFromGatewayByExternalCustomerId("external_customer_id") } @Test @@ -365,15 +338,8 @@ internal class CustomerServiceTest { .build() ) .taxConfiguration( - CustomerUpdateByExternalIdParams.TaxConfiguration.NewAvalaraTaxConfiguration - .builder() + CustomerUpdateByExternalIdParams.TaxConfiguration.Avalara.builder() .taxExempt(true) - .taxProvider( - CustomerUpdateByExternalIdParams.TaxConfiguration - .NewAvalaraTaxConfiguration - .TaxProvider - .AVALARA - ) .taxExemptionCode("tax_exemption_code") .build() ) diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceTest.kt index 253d2305..8b74b1d2 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/DimensionalPriceGroupServiceTest.kt @@ -6,7 +6,6 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.DimensionalPriceGroupCreateParams -import com.withorb.api.models.DimensionalPriceGroupRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -51,11 +50,7 @@ internal class DimensionalPriceGroupServiceTest { val dimensionalPriceGroupService = client.dimensionalPriceGroups() val dimensionalPriceGroup = - dimensionalPriceGroupService.retrieve( - DimensionalPriceGroupRetrieveParams.builder() - .dimensionalPriceGroupId("dimensional_price_group_id") - .build() - ) + dimensionalPriceGroupService.retrieve("dimensional_price_group_id") dimensionalPriceGroup.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/EventServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/EventServiceTest.kt index c6a90eb2..0fd938bc 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/EventServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/EventServiceTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue -import com.withorb.api.models.EventDeprecateParams import com.withorb.api.models.EventIngestParams import com.withorb.api.models.EventSearchParams import com.withorb.api.models.EventUpdateParams @@ -49,8 +48,7 @@ internal class EventServiceTest { .build() val eventService = client.events() - val response = - eventService.deprecate(EventDeprecateParams.builder().eventId("event_id").build()) + val response = eventService.deprecate("event_id") response.validate() } 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 50b47ed9..548a4035 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 @@ -6,13 +6,10 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.InvoiceCreateParams -import com.withorb.api.models.InvoiceFetchParams import com.withorb.api.models.InvoiceFetchUpcomingParams import com.withorb.api.models.InvoiceIssueParams import com.withorb.api.models.InvoiceMarkPaidParams -import com.withorb.api.models.InvoicePayParams import com.withorb.api.models.InvoiceUpdateParams -import com.withorb.api.models.InvoiceVoidInvoiceParams import com.withorb.api.models.PercentageDiscount import java.time.LocalDate import java.time.OffsetDateTime @@ -123,8 +120,7 @@ internal class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = - invoiceService.fetch(InvoiceFetchParams.builder().invoiceId("invoice_id").build()) + val invoice = invoiceService.fetch("invoice_id") invoice.validate() } @@ -194,7 +190,7 @@ internal class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = invoiceService.pay(InvoicePayParams.builder().invoiceId("invoice_id").build()) + val invoice = invoiceService.pay("invoice_id") invoice.validate() } @@ -208,10 +204,7 @@ internal class InvoiceServiceTest { .build() val invoiceService = client.invoices() - val invoice = - invoiceService.voidInvoice( - InvoiceVoidInvoiceParams.builder().invoiceId("invoice_id").build() - ) + val invoice = invoiceService.voidInvoice("invoice_id") invoice.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/ItemServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/ItemServiceTest.kt index 0822b77a..cf712a8f 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/ItemServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/ItemServiceTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.models.ItemCreateParams -import com.withorb.api.models.ItemFetchParams import com.withorb.api.models.ItemUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -78,7 +77,7 @@ internal class ItemServiceTest { .build() val itemService = client.items() - val item = itemService.fetch(ItemFetchParams.builder().itemId("item_id").build()) + val item = itemService.fetch("item_id") item.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/MetricServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/MetricServiceTest.kt index f0939c31..3b18a5d0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/MetricServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/MetricServiceTest.kt @@ -6,7 +6,6 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.MetricCreateParams -import com.withorb.api.models.MetricFetchParams import com.withorb.api.models.MetricUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -88,8 +87,7 @@ internal class MetricServiceTest { .build() val metricService = client.metrics() - val billableMetric = - metricService.fetch(MetricFetchParams.builder().metricId("metric_id").build()) + val billableMetric = metricService.fetch("metric_id") billableMetric.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt index 7dbc47d5..a6721a38 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PlanServiceTest.kt @@ -6,7 +6,6 @@ import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.PlanCreateParams -import com.withorb.api.models.PlanFetchParams import com.withorb.api.models.PlanUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -29,25 +28,22 @@ internal class PlanServiceTest { .currency("currency") .name("name") .addPrice( - PlanCreateParams.Price.NewPlanUnitPrice.builder() - .cadence(PlanCreateParams.Price.NewPlanUnitPrice.Cadence.ANNUAL) + PlanCreateParams.Price.Unit.builder() + .cadence(PlanCreateParams.Price.Unit.Cadence.ANNUAL) .itemId("item_id") - .modelType(PlanCreateParams.Price.NewPlanUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PlanCreateParams.Price.NewPlanUnitPrice.UnitConfig.builder() + PlanCreateParams.Price.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.BillingCycleConfiguration - .builder() + PlanCreateParams.Price.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .BillingCycleConfiguration + PlanCreateParams.Price.Unit.BillingCycleConfiguration .DurationUnit .DAY ) @@ -59,19 +55,17 @@ internal class PlanServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PlanCreateParams.Price.NewPlanUnitPrice.InvoicingCycleConfiguration - .builder() + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PlanCreateParams.Price.NewPlanUnitPrice - .InvoicingCycleConfiguration + PlanCreateParams.Price.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .metadata( - PlanCreateParams.Price.NewPlanUnitPrice.Metadata.builder() + PlanCreateParams.Price.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -140,7 +134,7 @@ internal class PlanServiceTest { .build() val planService = client.plans() - val plan = planService.fetch(PlanFetchParams.builder().planId("plan_id").build()) + val plan = planService.fetch("plan_id") plan.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt index e38bd275..369226f0 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/PriceServiceTest.kt @@ -7,7 +7,6 @@ import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.PriceCreateParams import com.withorb.api.models.PriceEvaluateParams -import com.withorb.api.models.PriceFetchParams import com.withorb.api.models.PriceUpdateParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test @@ -29,27 +28,23 @@ internal class PriceServiceTest { priceService.create( PriceCreateParams.builder() .body( - PriceCreateParams.Body.NewFloatingUnitPrice.builder() - .cadence(PriceCreateParams.Body.NewFloatingUnitPrice.Cadence.ANNUAL) + PriceCreateParams.Body.Unit.builder() + .cadence(PriceCreateParams.Body.Unit.Cadence.ANNUAL) .currency("currency") .itemId("item_id") - .modelType(PriceCreateParams.Body.NewFloatingUnitPrice.ModelType.UNIT) .name("Annual fee") .unitConfig( - PriceCreateParams.Body.NewFloatingUnitPrice.UnitConfig.builder() + PriceCreateParams.Body.Unit.UnitConfig.builder() .unitAmount("unit_amount") .build() ) .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.BillingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .BillingCycleConfiguration + PriceCreateParams.Body.Unit.BillingCycleConfiguration .DurationUnit .DAY ) @@ -60,20 +55,17 @@ internal class PriceServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration - .builder() + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration.builder() .duration(0L) .durationUnit( - PriceCreateParams.Body.NewFloatingUnitPrice - .InvoicingCycleConfiguration + PriceCreateParams.Body.Unit.InvoicingCycleConfiguration .DurationUnit .DAY ) .build() ) .metadata( - PriceCreateParams.Body.NewFloatingUnitPrice.Metadata.builder() + PriceCreateParams.Body.Unit.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() ) @@ -157,7 +149,7 @@ internal class PriceServiceTest { .build() val priceService = client.prices() - val price = priceService.fetch(PriceFetchParams.builder().priceId("price_id").build()) + val price = priceService.fetch("price_id") price.validate() } 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 97151c51..4fe649e8 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 @@ -5,8 +5,6 @@ package com.withorb.api.services.blocking import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.models.SubscriptionChangeApplyParams -import com.withorb.api.models.SubscriptionChangeCancelParams -import com.withorb.api.models.SubscriptionChangeRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,12 +20,7 @@ internal class SubscriptionChangeServiceTest { .build() val subscriptionChangeService = client.subscriptionChanges() - val subscriptionChange = - subscriptionChangeService.retrieve( - SubscriptionChangeRetrieveParams.builder() - .subscriptionChangeId("subscription_change_id") - .build() - ) + val subscriptionChange = subscriptionChangeService.retrieve("subscription_change_id") subscriptionChange.validate() } @@ -62,12 +55,7 @@ internal class SubscriptionChangeServiceTest { .build() val subscriptionChangeService = client.subscriptionChanges() - val response = - subscriptionChangeService.cancel( - SubscriptionChangeCancelParams.builder() - .subscriptionChangeId("subscription_change_id") - .build() - ) + val response = subscriptionChangeService.cancel("subscription_change_id") response.validate() } 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 cccf8e7e..a2e9dfd3 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 @@ -8,15 +8,11 @@ import com.withorb.api.core.JsonValue import com.withorb.api.models.SubscriptionCancelParams import com.withorb.api.models.SubscriptionCreateParams import com.withorb.api.models.SubscriptionFetchCostsParams -import com.withorb.api.models.SubscriptionFetchParams -import com.withorb.api.models.SubscriptionFetchScheduleParams import com.withorb.api.models.SubscriptionFetchUsageParams import com.withorb.api.models.SubscriptionPriceIntervalsParams import com.withorb.api.models.SubscriptionSchedulePlanChangeParams import com.withorb.api.models.SubscriptionTriggerPhaseParams -import com.withorb.api.models.SubscriptionUnscheduleCancellationParams import com.withorb.api.models.SubscriptionUnscheduleFixedFeeQuantityUpdatesParams -import com.withorb.api.models.SubscriptionUnschedulePendingPlanChangesParams import com.withorb.api.models.SubscriptionUpdateFixedFeeQuantityParams import com.withorb.api.models.SubscriptionUpdateParams import com.withorb.api.models.SubscriptionUpdateTrialParams @@ -44,15 +40,8 @@ internal class SubscriptionServiceTest { .addAddAdjustment( SubscriptionCreateParams.AddAdjustment.builder() .adjustment( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount + SubscriptionCreateParams.AddAdjustment.Adjustment.PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -94,26 +83,14 @@ internal class SubscriptionServiceTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionCreateParams.AddPrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionCreateParams.AddPrice.Price.Unit.builder() .cadence( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Cadence - .ANNUAL + SubscriptionCreateParams.AddPrice.Price.Unit.Cadence.ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .UnitConfig + SubscriptionCreateParams.AddPrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -121,14 +98,12 @@ internal class SubscriptionServiceTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -141,14 +116,12 @@ internal class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -156,9 +129,7 @@ internal class SubscriptionServiceTest { .build() ) .metadata( - SubscriptionCreateParams.AddPrice.Price - .NewSubscriptionUnitPrice - .Metadata + SubscriptionCreateParams.AddPrice.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -217,14 +188,8 @@ internal class SubscriptionServiceTest { SubscriptionCreateParams.ReplaceAdjustment.builder() .adjustment( SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionCreateParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -265,26 +230,15 @@ internal class SubscriptionServiceTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionCreateParams.ReplacePrice.Price.NewSubscriptionUnitPrice - .builder() + SubscriptionCreateParams.ReplacePrice.Price.Unit.builder() .cadence( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Cadence + SubscriptionCreateParams.ReplacePrice.Price.Unit.Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .UnitConfig + SubscriptionCreateParams.ReplacePrice.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -292,14 +246,12 @@ internal class SubscriptionServiceTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -312,14 +264,12 @@ internal class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionCreateParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -327,9 +277,7 @@ internal class SubscriptionServiceTest { .build() ) .metadata( - SubscriptionCreateParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .Metadata + SubscriptionCreateParams.ReplacePrice.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -422,10 +370,7 @@ internal class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val subscription = - subscriptionService.fetch( - SubscriptionFetchParams.builder().subscriptionId("subscription_id").build() - ) + val subscription = subscriptionService.fetch("subscription_id") subscription.validate() } @@ -462,10 +407,7 @@ internal class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val page = - subscriptionService.fetchSchedule( - SubscriptionFetchScheduleParams.builder().subscriptionId("subscription_id").build() - ) + val page = subscriptionService.fetchSchedule("subscription_id") page.response().validate() } @@ -528,7 +470,7 @@ internal class SubscriptionServiceTest { .expiresAtEndOfCadence(true) .build() ) - .addAmountDiscountCreationParamsDiscount(0.0) + .addAmountDiscount(0.0) .endDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .externalPriceId("external_price_id") .filter("my_property > 100 AND my_other_property = 'bar'") @@ -542,27 +484,16 @@ internal class SubscriptionServiceTest { .maximumAmount(0.0) .minimumAmount(0.0) .price( - SubscriptionPriceIntervalsParams.Add.Price.NewFloatingUnitPrice - .builder() + SubscriptionPriceIntervalsParams.Add.Price.Unit.builder() .cadence( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .Cadence + SubscriptionPriceIntervalsParams.Add.Price.Unit.Cadence .ANNUAL ) .currency("currency") .itemId("item_id") - .modelType( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .UnitConfig + SubscriptionPriceIntervalsParams.Add.Price.Unit.UnitConfig .builder() .unitAmount("unit_amount") .build() @@ -570,14 +501,12 @@ internal class SubscriptionServiceTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -589,14 +518,12 @@ internal class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice + SubscriptionPriceIntervalsParams.Add.Price.Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -604,9 +531,7 @@ internal class SubscriptionServiceTest { .build() ) .metadata( - SubscriptionPriceIntervalsParams.Add.Price - .NewFloatingUnitPrice - .Metadata + SubscriptionPriceIntervalsParams.Add.Price.Unit.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -621,14 +546,8 @@ internal class SubscriptionServiceTest { SubscriptionPriceIntervalsParams.AddAdjustment.builder() .adjustment( SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionPriceIntervalsParams.AddAdjustment.Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -688,15 +607,8 @@ internal class SubscriptionServiceTest { SubscriptionSchedulePlanChangeParams.AddAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.AddAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.AddAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -742,26 +654,16 @@ internal class SubscriptionServiceTest { .minimumAmount("1.23") .planPhaseOrder(0L) .price( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .builder() + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit.builder() .cadence( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .UnitConfig .builder() .unitAmount("unit_amount") @@ -770,14 +672,13 @@ internal class SubscriptionServiceTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + .Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -790,14 +691,13 @@ internal class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + .Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -805,8 +705,7 @@ internal class SubscriptionServiceTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.AddPrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.AddPrice.Price.Unit .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -860,15 +759,8 @@ internal class SubscriptionServiceTest { SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.builder() .adjustment( SubscriptionSchedulePlanChangeParams.ReplaceAdjustment.Adjustment - .NewPercentageDiscount + .PercentageDiscount .builder() - .adjustmentType( - SubscriptionSchedulePlanChangeParams.ReplaceAdjustment - .Adjustment - .NewPercentageDiscount - .AdjustmentType - .PERCENTAGE_DISCOUNT - ) .addAppliesToPriceId("price_1") .addAppliesToPriceId("price_2") .percentageDiscount(0.0) @@ -912,26 +804,17 @@ internal class SubscriptionServiceTest { .maximumAmount("1.23") .minimumAmount("1.23") .price( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .builder() .cadence( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .Cadence .ANNUAL ) .itemId("item_id") - .modelType( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice - .ModelType - .UNIT - ) .name("Annual fee") .unitConfig( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .UnitConfig .builder() .unitAmount("unit_amount") @@ -940,15 +823,14 @@ internal class SubscriptionServiceTest { .billableMetricId("billable_metric_id") .billedInAdvance(true) .billingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .BillingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.ReplacePrice .Price - .NewSubscriptionUnitPrice + .Unit .BillingCycleConfiguration .DurationUnit .DAY @@ -961,15 +843,14 @@ internal class SubscriptionServiceTest { .fixedPriceQuantity(0.0) .invoiceGroupingKey("invoice_grouping_key") .invoicingCycleConfiguration( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .InvoicingCycleConfiguration .builder() .duration(0L) .durationUnit( SubscriptionSchedulePlanChangeParams.ReplacePrice .Price - .NewSubscriptionUnitPrice + .Unit .InvoicingCycleConfiguration .DurationUnit .DAY @@ -977,8 +858,7 @@ internal class SubscriptionServiceTest { .build() ) .metadata( - SubscriptionSchedulePlanChangeParams.ReplacePrice.Price - .NewSubscriptionUnitPrice + SubscriptionSchedulePlanChangeParams.ReplacePrice.Price.Unit .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -1028,12 +908,7 @@ internal class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = - subscriptionService.unscheduleCancellation( - SubscriptionUnscheduleCancellationParams.builder() - .subscriptionId("subscription_id") - .build() - ) + val response = subscriptionService.unscheduleCancellation("subscription_id") response.validate() } @@ -1067,12 +942,7 @@ internal class SubscriptionServiceTest { .build() val subscriptionService = client.subscriptions() - val response = - subscriptionService.unschedulePendingPlanChanges( - SubscriptionUnschedulePendingPlanChangesParams.builder() - .subscriptionId("subscription_id") - .build() - ) + val response = subscriptionService.unschedulePendingPlanChanges("subscription_id") response.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceTest.kt index 7c781eb9..de8b4fe1 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/coupons/SubscriptionServiceTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.services.blocking.coupons import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient -import com.withorb.api.models.CouponSubscriptionListParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -20,10 +19,7 @@ internal class SubscriptionServiceTest { .build() val subscriptionService = client.coupons().subscriptions() - val page = - subscriptionService.list( - CouponSubscriptionListParams.builder().couponId("coupon_id").build() - ) + val page = subscriptionService.list("coupon_id") page.response().validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceTest.kt index 7e4e5a11..31278e92 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/BalanceTransactionServiceTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.blocking.customers import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.models.CustomerBalanceTransactionCreateParams -import com.withorb.api.models.CustomerBalanceTransactionListParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -43,10 +42,7 @@ internal class BalanceTransactionServiceTest { .build() val balanceTransactionService = client.customers().balanceTransactions() - val page = - balanceTransactionService.list( - CustomerBalanceTransactionListParams.builder().customerId("customer_id").build() - ) + val page = balanceTransactionService.list("customer_id") page.response().validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/CreditServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/CreditServiceTest.kt index 5254598f..aceb4f89 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/CreditServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/CreditServiceTest.kt @@ -4,8 +4,6 @@ package com.withorb.api.services.blocking.customers import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient -import com.withorb.api.models.CustomerCreditListByExternalIdParams -import com.withorb.api.models.CustomerCreditListParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -21,8 +19,7 @@ internal class CreditServiceTest { .build() val creditService = client.customers().credits() - val page = - creditService.list(CustomerCreditListParams.builder().customerId("customer_id").build()) + val page = creditService.list("customer_id") page.response().validate() } @@ -36,12 +33,7 @@ internal class CreditServiceTest { .build() val creditService = client.customers().credits() - val page = - creditService.listByExternalId( - CustomerCreditListByExternalIdParams.builder() - .externalCustomerId("external_customer_id") - .build() - ) + val page = creditService.listByExternalId("external_customer_id") page.response().validate() } 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 3befebde..65c238cc 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 @@ -7,8 +7,6 @@ import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue import com.withorb.api.models.CustomerCreditLedgerCreateEntryByExternalIdParams import com.withorb.api.models.CustomerCreditLedgerCreateEntryParams -import com.withorb.api.models.CustomerCreditLedgerListByExternalIdParams -import com.withorb.api.models.CustomerCreditLedgerListParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,10 +23,7 @@ internal class LedgerServiceTest { .build() val ledgerService = client.customers().credits().ledger() - val page = - ledgerService.list( - CustomerCreditLedgerListParams.builder().customerId("customer_id").build() - ) + val page = ledgerService.list("customer_id") page.response().validate() } @@ -47,24 +42,14 @@ internal class LedgerServiceTest { CustomerCreditLedgerCreateEntryParams.builder() .customerId("customer_id") .body( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + CustomerCreditLedgerCreateEntryParams.Body.Increment.builder() .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) .currency("currency") .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .InvoiceSettings + CustomerCreditLedgerCreateEntryParams.Body.Increment.InvoiceSettings .builder() .autoCollection(true) .netTerms(0L) @@ -73,9 +58,7 @@ internal class LedgerServiceTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .Metadata + CustomerCreditLedgerCreateEntryParams.Body.Increment.Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) .build() @@ -103,23 +86,14 @@ internal class LedgerServiceTest { CustomerCreditLedgerCreateEntryByExternalIdParams.builder() .externalCustomerId("external_customer_id") .body( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .builder() + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment.builder() .amount(0.0) - .entryType( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams - .EntryType - .INCREMENT - ) .currency("currency") .description("description") .effectiveDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .expiryDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .invoiceSettings( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .InvoiceSettings .builder() .autoCollection(true) @@ -129,8 +103,7 @@ internal class LedgerServiceTest { .build() ) .metadata( - CustomerCreditLedgerCreateEntryByExternalIdParams.Body - .AddIncrementCreditLedgerEntryRequestParams + CustomerCreditLedgerCreateEntryByExternalIdParams.Body.Increment .Metadata .builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -154,12 +127,7 @@ internal class LedgerServiceTest { .build() val ledgerService = client.customers().credits().ledger() - val page = - ledgerService.listByExternalId( - CustomerCreditLedgerListByExternalIdParams.builder() - .externalCustomerId("external_customer_id") - .build() - ) + val page = ledgerService.listByExternalId("external_customer_id") page.response().validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceTest.kt index eb9247ec..4c3d2daa 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/customers/credits/TopUpServiceTest.kt @@ -8,8 +8,6 @@ import com.withorb.api.models.CustomerCreditTopUpCreateByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpCreateParams import com.withorb.api.models.CustomerCreditTopUpDeleteByExternalIdParams import com.withorb.api.models.CustomerCreditTopUpDeleteParams -import com.withorb.api.models.CustomerCreditTopUpListByExternalIdParams -import com.withorb.api.models.CustomerCreditTopUpListParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -60,10 +58,7 @@ internal class TopUpServiceTest { .build() val topUpService = client.customers().credits().topUps() - val page = - topUpService.list( - CustomerCreditTopUpListParams.builder().customerId("customer_id").build() - ) + val page = topUpService.list("customer_id") page.response().validate() } @@ -147,12 +142,7 @@ internal class TopUpServiceTest { .build() val topUpService = client.customers().credits().topUps() - val page = - topUpService.listByExternalId( - CustomerCreditTopUpListByExternalIdParams.builder() - .externalCustomerId("external_customer_id") - .build() - ) + val page = topUpService.listByExternalId("external_customer_id") page.response().validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceTest.kt index 489d65b5..4831999e 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/dimensionalPriceGroups/ExternalDimensionalPriceGroupIdServiceTest.kt @@ -4,7 +4,6 @@ package com.withorb.api.services.blocking.dimensionalPriceGroups import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient -import com.withorb.api.models.DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,11 +21,7 @@ internal class ExternalDimensionalPriceGroupIdServiceTest { client.dimensionalPriceGroups().externalDimensionalPriceGroupId() val dimensionalPriceGroup = - externalDimensionalPriceGroupIdService.retrieve( - DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.builder() - .externalDimensionalPriceGroupId("external_dimensional_price_group_id") - .build() - ) + externalDimensionalPriceGroupIdService.retrieve("external_dimensional_price_group_id") dimensionalPriceGroup.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/BackfillServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/BackfillServiceTest.kt index 4cbbe182..62a9f2e3 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/BackfillServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/events/BackfillServiceTest.kt @@ -4,10 +4,7 @@ package com.withorb.api.services.blocking.events import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient -import com.withorb.api.models.EventBackfillCloseParams import com.withorb.api.models.EventBackfillCreateParams -import com.withorb.api.models.EventBackfillFetchParams -import com.withorb.api.models.EventBackfillRevertParams import java.time.OffsetDateTime import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -63,10 +60,7 @@ internal class BackfillServiceTest { .build() val backfillService = client.events().backfills() - val response = - backfillService.close( - EventBackfillCloseParams.builder().backfillId("backfill_id").build() - ) + val response = backfillService.close("backfill_id") response.validate() } @@ -80,10 +74,7 @@ internal class BackfillServiceTest { .build() val backfillService = client.events().backfills() - val response = - backfillService.fetch( - EventBackfillFetchParams.builder().backfillId("backfill_id").build() - ) + val response = backfillService.fetch("backfill_id") response.validate() } @@ -97,10 +88,7 @@ internal class BackfillServiceTest { .build() val backfillService = client.events().backfills() - val response = - backfillService.revert( - EventBackfillRevertParams.builder().backfillId("backfill_id").build() - ) + val response = backfillService.revert("backfill_id") response.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceTest.kt index e904d737..1dc620ee 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/plans/ExternalPlanIdServiceTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.blocking.plans import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue -import com.withorb.api.models.PlanExternalPlanIdFetchParams import com.withorb.api.models.PlanExternalPlanIdUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -47,10 +46,7 @@ internal class ExternalPlanIdServiceTest { .build() val externalPlanIdService = client.plans().externalPlanId() - val plan = - externalPlanIdService.fetch( - PlanExternalPlanIdFetchParams.builder().externalPlanId("external_plan_id").build() - ) + val plan = externalPlanIdService.fetch("external_plan_id") plan.validate() } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceTest.kt index b511ec59..71781f47 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/services/blocking/prices/ExternalPriceIdServiceTest.kt @@ -5,7 +5,6 @@ package com.withorb.api.services.blocking.prices import com.withorb.api.TestServerExtension import com.withorb.api.client.okhttp.OrbOkHttpClient import com.withorb.api.core.JsonValue -import com.withorb.api.models.PriceExternalPriceIdFetchParams import com.withorb.api.models.PriceExternalPriceIdUpdateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -46,12 +45,7 @@ internal class ExternalPriceIdServiceTest { .build() val externalPriceIdService = client.prices().externalPriceId() - val price = - externalPriceIdService.fetch( - PriceExternalPriceIdFetchParams.builder() - .externalPriceId("external_price_id") - .build() - ) + val price = externalPriceIdService.fetch("external_price_id") price.validate() }